0

I just stumbled over this SE answer about navigating to LWC components by directly calling a URL.

this[NavigationMixin.Navigate]({
    type: 'standard__webPage',
    attributes: {
        url: '/one/one.app#' + btoa(JSON.stringify({"componentDef" : "c:sendQuoteEmail"}))
    }
})

It works quite well for me and I wonder if this is documented and safe to use, or if I should avoid doing it...

While doing some research about the componentDef, I stumbled over some references to the deprecated aura navigation using e.force:navigateToComponent, so I wonder if this hidden feature is some aura legacy that might stay around untouched for some time ;)

1
  • 1
    It's undocumented and could break. I wouldn't do it myself (but then I work for an ISV so we cannot use this sort of hack as it may impact a lot of customers if the hack stops working).
    – Phil W
    Commented Feb 21 at 17:03

1 Answer 1

0

The final link in your question contains your answer. Use lightning:navigation or lightning-navigation using the type standard__component rather than encoding a payload with standard__webPage. This method should be reliable for years to come.

2
  • The downside here is, that it does not support LWC but only aura, and with the URL hack I am able to avoid an additional wrapper component. I am tired of aura wrappers, to be honest...
    – itsmebasti
    Commented Feb 21 at 20:35
  • @itsmebasti It's probably low priority, given that there are workarounds, though. For example, a single Aura component could have a parameter to initialize a LWC dynamically.
    – sfdcfox
    Commented Feb 21 at 21:16

You must log in to answer this question.

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