I am building a LWC that uses the pageReference that is not available in Communities.

Is there a way to check what context you are in from the LWC, whether it's in a community, a record page, or something else?

  • There’s a way to identify at least if its on a record page or not. – Jayant Das Sep 13 '19 at 22:43
  • You can call apex, and in apex you can call URL.getSalesforceBaseUrl().toExternalForm(); to get the URL from where the request originated, then you can compare it with `salesforce.stackexchange.com/questions/88329/… to dertermine if you are in a community or not – Pranay Jaiswal Sep 17 '19 at 18:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.