2

I am trying to set up some links to navigate to other pages in a Salesforce Community/Digital Experience site. I have an existing LWC that used the navigation mixin to get this to work within a Build Your Own (Aura) community. However when I try this in the LWR version, I can't seem to get navigation to work. The following snippet works in the aura community and the LWC is API Version 48

this[NavigationMixin.Navigate]({
            type: 'comm__namedPage',
            attributes: {
               pageName: 'practice'
            }
            });

I've tried switching to the attribute of "name" instead of page name, and in there I have tried also using the api name of the page (+ __c) and I always get an Invalid Page error with this message "A URL cannot be created to navigate to route "comm__namedPage"

What is the correct way to navigate to other pages in a Build Your Own LWR community? Could this be a bug?

1 Answer 1

1

You need to distinguish between different types of pages (record, internal page, external page) and update the navigation object accordingly.

E.g. this snippet should work for any internal page

{
    type: 'standard__objectPage',
    attributes: {
        objectApiName: target
    },
    state: {
        filterName: defaultListViewId
}

Taken from this salesfroce sample app.

And also check out this tutorial from salesforce about how to build lwr sites.

You must log in to answer this question.

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