Directly Navigate to Lightning Web Component without Using Aura Component

Lightning Web Component framework allows you to navigate to Lightning Web Component from another Lightning Web Component using Using PageReference Object of Lightning Component Type(Works only in Lightning Experience, Salesforce Mobile App). The problem here is you need to create one additional Aura Component having lightning:isUrlAddressable added as interface to enable direct navigation to a Lightning Component via URL. In this blog, We are going to see a way to navigate to Lightning Web Component directly from another Lightning Web Component without needing any Aura Component.

Let’s Create two Lightning Web Component to test out this feature. They are:-

  1. navigateFromLwc
  2. targetLwcComponent

In our use case, There will be a button on navigateFromLwc which will navigate users to targetLwcComponent.


This html file has a button with label name Navigate To LWC which will navigate user to another lightning web component onclick of it.

    <lightning-button variant="success" label="Navigate To LWC" title="Successful action" onclick={handleNavigate}


The js file has the handleNavigate method defined bind with button in html markup. It will create a URL in Base64 encoded form. This URL will be later used with lightning-navigation service to navigate to the component using PageReference Object of web page Type.

import { LightningElement } from 'lwc';
import { NavigationMixin } from 'lightning/navigation';
export default class NavigateFromLwc extends NavigationMixin(LightningElement) {
    handleNavigate() {
        var compDefinition = {
            componentDef: "c:targetLwcComponent",
            attributes: {
                propertyValue: "500"
        // Base64 encode the compDefinition JS object
        var encodedCompDef = btoa(JSON.stringify(compDefinition));
            type: 'standard__webPage',
            attributes: {
                url: '/one/' + encodedCompDef


<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="">

Let’s see the code for targetLwcComponent Lightning Web Component.


The html file of this component has the property value passed with navigation to Lightning Web Component.

    Navigated from LWC with property Value is : {propertyValue}


The public property here can be set from any other component. In our case, we are passing the value of the property of this component from another component.

import { LightningElement, api } from 'lwc';

export default class TargetLwcComponent extends LightningElement {
    @api propertyValue;


<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="">

Demo – Navigate Directly To Lightning Web Component


  1. Hi, how do we resolve the issue of Navigation happening twice? I followed the code in this example, the only difference is I’m using modal for the “navigateFromLwc”.

  2. i implemented the same but when the component is opening in new tab the tab name is Loading with loading icon. I need to name the tab where the LWC is opening.

  3. Can you please tell me that whether the lwc components can be added to the lightning community page or not?

Leave a Reply