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

Navigate from a Lightning Component to Another

Hello, I am working on lightning component and stuck on scenario is there any way to switch one lightning component to another component when both are in different lightning pages.  
Please Help Me.
Thanks In Advance. :)
Best Answer chosen by Bharat.Sharma
This event is handled by the container. It’s supported in Lightning Experience and Salesforce app only.

All Answers
Hi bharat, use e.force:navigateToComponent​ for Navigate to another component 
navigateToMyComponent : function(component, event, helper) {
    var evt = $A.get("e.force:navigateToComponent");
        componentDef : "c:myComponent",
        componentAttributes: {
            contactName : component.get("")

for refernece : 

Thanks, let me inform if it helps you 
Amit Singh 1Amit Singh 1
+1 Piyush,

This is what you need to Navigate from one component to another 

Thanks Piyush for very fast reply, I am trying the same but getting error :

[Cannot read property 'setParams' of undefined] 

Here evt variable getting undifined , i am checking in console.log(evt).
This event is handled by the container. It’s supported in Lightning Experience and Salesforce app only.
This was selected as the best answer

Thank you Piyush for the help its working fine now !!

David Roberts 4David Roberts 4
Many thanks form me, too, Piyush. Great post!
David Roberts 4David Roberts 4
e.force:navigateToComponent is deprecated.
How do I navigate to an account page.
I'm getting a setparams error using Raj Vakati's sample at:

var navService = cmp.find("navigateToAccount");
        console.log('nav service: '+navService);  
        var pageReference = {
            type: "standard__objectPage",
            attributes: {
                objectApiName: "Account",
                actionName: "list"
            state: {}
        console.log('navTo: '+ pageReference);
        cmp.set("v.pageReference", pageReference);
        var defaultUrl = "#";
        .then($A.getCallback(function(url) {
            cmp.set("v.url", url ? url : defaultUrl);
        }), $A.getCallback(function(error) {
            console.log('there was an error: '+error);
            cmp.set("v.url", defaultUrl);
Ankita Rustagi 26Ankita Rustagi 26
@Piyush_soni, @Bharat.sharma.. what was the resolution for evt param undefined error. Kindly share. Facing the same issue.