I have several LWC's which interact with other LWC's on Custom App Page using Lightning Message Channel.

When you open the Page in Lightning App Builder these several LWC's is not visible.
They become visible after some action (pressing the button etc.)

And it is quite hard to configure the Page as when you put a LWC on a Page it is empty(not visible) :

enter image description here

So my question is :
Is there a way to determine if the LWC is opened from Lightning App Builder ? (to show some default preview for a user (Name and description of LWC)

I tried to check the page url, it looks in next way :


So we can check if the page url contains /flexipageEditor/ value ?
However I am not sure if is good and stable solution ?

Any help will be appreciated.
Thank You.

2 Answers 2


As mentioned in Tips for Working with Lightning App Builder, they recommend:

  • Make components fill 100% of the width (including margins) of the region that they display in. See Make a Component Width-Aware.
  • If components require interaction, provide an appropriate placeholder behavior in Lightning App Builder.
  • Don’t display a blank box. Think of how other sites work. For example, Facebook displays an outline of the feed before the actual feed items come back from the server. The outline improves the user’s perception of UI responsiveness.
  • If a component depends on a fired event, give it a default state that displays before the event fires.
  • Use Salesforce Design System to style components.

In other words, you should provide some kind of loading template that appears before the component is fully loaded. This will prevent the builder from showing a blank space rather than the actual component, and make it easier to interact with it.

You should not generally need to determine if the component is in the builder or not if you provide a default view, and having such a view improves the overall UX, so this is really taking care of two problems at the same time.


Could you do something like:

import { LightningElement } from 'lwc';

export default class MyComponent extends LightningElement {
    get isAppBuilderContext() {
        return window.location.href.includes('/flexipageEditor/surface.app');
  • 1
    Yeah, I do use window.location.href.indexOf('/flexipageEditor/surface.app') and it works pretty good for almost a year. Commented Jan 15 at 16:38

You must log in to answer this question.

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