function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
gajawada vaishnavigajawada vaishnavi 

navigation between lwc

I want to navigate from one lwc to other lwc or lwc to vf page in salesforce community guest page .
I have used navigation code as below:-
-->for lwc
handleNavigate() {
        var compDefinition = {
            componentDef: "c:thankyouLeadLwc"
            
        }
        var encodedCompDef = btoa(JSON.stringify(compDefinition));
    this[NavigationMixin.Navigate]({
        type: 'standard__component',
        attributes: {
            componentName: "c__thankyouLeadLwc",
            url: '/one/one.app#' + encodedCompDef
        }
    });
-->for vf page
    handleNavigate(){
            this[NavigationMixin.GenerateUrl]({
                type: 'standard__webPage',
                attributes: {
                    url: '/apex/Thank_You_Page?'
                }
            }).then(vfURL => {
            window.open(vfURL);
            });
        }
        both the codes are not working...if I use lwc to lwc it is not at all navigating
but from lwc to vf page I am getting page not available

Someone's help is highly apprciated
    
AnudeepAnudeep (Salesforce Developers) 
componentName is the only attribute for type standard__component as per the documentation
 
{    
    "type": "standard__component",
    "attributes": {
        "componentName": "c__MyLightningComponent"    
    },    
    "state": {
        "myAttr": "attrValue"    
    }
}

Whereas for standard_webPage url is an attribute
 
{    
    "type": "standard__webPage",
    "attributes": {
        "url": "http://salesforce.com"
    }
}

I recommend trying with the above syntax using a sample URL 

Let me know if this helps, if it does, please close the query by marking it as solved. It may help others in the community. Thank You!
gajawada vaishnavigajawada vaishnavi
Hi Anudeep
Thanks for the reply
{ "type": "standard__component", "attributes": { "componentName": "c__MyLightningComponent" }, "state": { "myAttr": "attrValue" } }
Here what is the state attribute?