Navigation Service in LWC

By | August 18, 2022

In this blog, we are going to discuss “Navigation Service in LWC” which is used to create a new account from an Account record page. This is not just limited to creating a new account you can perform various other tasks with it like going to the account list view, Creating a contact from the account screen, etc.

Navigation Service in LWC

Here are the steps to use the navigation service.

  • Navigation service uses a PageReference.And a page reference is JavaScript that describes its page type, its attributes, and the state of the page.
  • First, we need to import the lightning/navigation module.
  • Use this Syntax:-   Import {NavigationMixin} from ‘lightning/navigation;

Apply the NavigationMixin function to your component’s base Class.

Syntax: Export default class MyCustomElement extends NavigationMixin(LightningElement) {}

  • Create a javascript that defines a page.
  • In javascript call the navigation services that are [NavigationMixin.Navigate] page reference.
  • Example:
navigateNext() {
           type: 'standard__navItemPage',
           attributes: {
               apiName: this.tabName,
  • The component NavigationMixin.Navigate is used to navigate another page in the application.
  • Now let’s see an example of this:-
  • First, create an Html page in LWC.  
Navigation Service in LWC Or Navigate Service Html Code
Navigate Service Html Code
  • Then call the action i.e Onclick javascript controller.
Navigate Service JavaScript Code
Navigate Service JavaScript Code
  • Then create an XML page to show the navigation work on UI.
Navigate Service Meta XML Code
Navigate Service Meta XML Code
Note: You can show this in any object on the lightning record page, home page, and also the App page.
  • Now let’s add this navigate button on the record page of the account.
  • To add this button go to the edit page and drag your custom component named navigateservice, then click on save and active.
Account Record Page
Account Record Page

Using the details mentioned in the steps above, we hope you are be able to undertand on “Navigation Service in LWC”. You can find more details on Navigation and Salesforce on their help page here.

We hope you may find this blog resourceful and helpful. If you still have concerns and need more help, please get in touch with us at

About Us
Greytrix – a globally recognized and one of the oldest Sage Development Partner and a Salesforce Product development partner offers a wide variety of integration products and services to the end users as well as to the Partners and Sage PSG across the globe. We offer Consultation, Configuration, Training and support services in out-of-the-box functionality as well as customizations to incorporate custom business rules and functionalities that require apex code incorporation into the Salesforce platform.

Greytrix has some unique solutions for Cloud CRM such as Salesforce Sage integration for Sage X3Sage 100 and Sage 300 (Sage Accpac). We also offer best-in-class Cloud CRM Salesforce customization and development services along with services such as Salesforce Data MigrationIntegrated App developmentCustom App development and Technical Support to business partners and end users.
Salesforce Cloud CRM integration offered by Greytrix works with Lightning web components and supports standard opportunity workflow. Greytrix GUMU™ integration for Sage ERP – Salesforce is a 5-star rated app listed on Salesforce AppExchange.

The GUMU™ Cloud framework by Greytrix forms the backbone of cloud integrations that are managed in real-time for processing and execution of application programs at the click of a button.

For more information on our Salesforce products and services, contact us at We will be glad to assist you.

Related Posts