Navigate a user to a record page in edit mode in LWC

Let's look at how to Navigate a user to a record page in edit mode in LWC.

In case you are interested in navigating an user to the standard edit form on click of a button (not using quick actions) then we can use NavigationMixin

In a way, this is similar to e.force:editRecord in Aura

Here is the snippet!

  • We are importing NavigationMixin from lightning/navigation
  • We are providing a config object to this[NavigationMixin.Navigate]
  • The config object is going to have information about the destination. The key is providing edit for the key actionName
import { LightningElement } from "lwc";

import { NavigationMixin } from "lightning/navigation";

export default class ExploreNavigation extends NavigationMixin(
  LightningElement
) {
  handleNavigate() {
    const config = {
      type: "standard__recordPage",
      attributes: {
        recordId: "00QXXXXXXXXXXlEAJ",
        objectApiName: "Lead",
        actionName: "edit"
      }
    };
    this[NavigationMixin.Navigate](config);
  }
}
Using NavigationMixin in LWC to open a record in edit mode

Hope this helps!