I have encountered the same problem as the unanswered question found here: backgroundContext not working for Edit NavigationMixin LWC

backgroundContext does not appear to work in this scenario - so I have tried many other parameters to no success:

  • inContextOf - a base64 encoded string of a page reference. I have used this successfully in Aura components
  • saveNewUrl - similar to backgroundContext, does not work. found from a record type selection screen url: enter image description here Some guessed urls based off what I've seen can be used in class:
    • cancelUrl - similar to backgroundContext, does not work
    • saveUrl- similar to backgroundContext, does not work

Is there any state variable that anyone can suggest? This state object is highly undocumented and has been a process of trial and error getting this to work in LWC.

    let pageReference = {
        type: 'standard__recordPage',
        attributes: {
            recordId: contactId,
            objectApiName: 'Contact',
            actionName: 'edit'
        state: {
            nooverride: '1'
            //,backgroundContext: testUrl //works for view
            //,inContextOfRef: '1.' + window.btoa(JSON.stringify(inContextOf))
            //,saveNewUrl: testUrl
            //,saveUrl: testUrl
            //,cancelUrl: testUrl

1 Answer 1


You should add in state the navigationLocation attribute. I have resolved the problem for the backgroundContext by adding it (see the linked question for the details and a full example).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.