How can I add some parameters in the new component in NavigationMixin?
I am using NavigationMixin to navigate from one lwc to another lwc (app page in a custom tab) like this:
navigateToTabPage() { // Navigate to a specific CustomTab. this[NavigationMixin.Navigate]({ type: 'standard__navItemPage', attributes: { apiName: 'TABNAME' } }); }
How can I add some parameters (for example an Id) and how can I handle this parameters in the new component ?
To add some parameters in the new component in NavigationMixin -
standard__navItemPage PageReference Type does not have any property other than apiName which is the unique name of the CustomTab. It means you can not pass anything other than that.
You should use standard__component PageReference Type. To make an addressable Lightning web component, embed it in an Aura component that implements the lightning:isUrlAddressable interface.
{ type: 'standard__component', attributes: { componentName: 'c__MyLightningComponent' }, state: { c__counter: '5' } }
You can pass any key and value in the state object. The key must include a namespace, and the value must be a string.