We have a use case where a lightning component built in LWC, should trigger a URL change.

We're handling that with the history.replaceState method(note that we encountered the same problem with history.pushState).

In the other hand, upon a URL change an Aura Component should rerender/reflect this change.


Neither of the standard events forceCommunity:routeChange or aura:locationChange are able to pickup the URL change.

Is this a bug or these events are not supposed to pickup such kind of URL change?

Reproducing the problem:

In order to reproduce this scenario I've built a basic demo app, that can be found & deployed from this repo.

  • I think that is because the pushState never causes a hashchange event to be fired and I belive the two salesforce events you have mentioned listen for this standard event to detect the change.
    – manjit5190
    Commented Oct 5, 2020 at 21:23
  • Disregarding for a bit the using either/or pushState/replaceStat, both of them change the URL, and yes if aura:locatonShange detects on hash changes, the forceCommunity:routeChange should detect it, at least as per what the documentation states: developer.salesforce.com/docs/component-library/bundle/… Commented Oct 6, 2020 at 8:00


You must log in to answer this question.