I create an aura component which can used in Lightning App Builder. I want to implement this feature: when in Lightning App Builder just show diagram.

So I want to ask about is there anyway to know aura component run under Lightning App Builder or not?

In this Aura Component, I used follow method to check if Aura Component run under Lightning App Builder or not, is this a correct way?

var inLightningAppBuilder = window.location.href.indexOf('flexipageEditor/surface.app?') >= 0;
  • 2
    Why do you need to know?
    – sfdcfox
    Commented Nov 3, 2020 at 3:45
  • Sorry for replied late. My company product want to our aura component show different style in Lightning App Builder. I found an idea to check by using follow code: "var inLightningAppBuilder = window.location.href.indexOf('flexipageEditor/surface.app?') >= 0;" But we don't if this a good idea or not.
    – GhostLee
    Commented Nov 5, 2020 at 2:01
  • 1
    There is no supported way to do this. Components shouldn't know what context they render in, they should behave appropriately based on the data/capabilities that are available.
    – Kristian
    Commented Dec 7, 2020 at 3:36
  • Thanks for your replied.
    – GhostLee
    Commented Dec 7, 2020 at 5:38

1 Answer 1


Looks like no supported way in salesforce to do this.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .