I am trying to call an LWC and pass the Id. However the second LWC variable is undefined.

First LWC:

            type: 'standard__navItemPage',
            attributes: {
                apiName: 'secondLWC',
            state: {
                c__recordId: 'someId...'

The second LWC Opens but when RenderedCallback runs "recordId" us undefined


renderedCallback() {
    console.log('In renderedCallback');
    console.log('recordId: ', this.recordId); //undefined

1 Answer 1


You need to get recordId from the URL.

getStateParameters(currentPageReference) {
   if (currentPageReference) {
       this.recordId = currentPageReference.state?.c__recordId;

More details here https://beyondthecloud.dev/blog/get-url-parameters-in-lwc

You must log in to answer this question.

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