Hi you can use the below code
use the below component--https://developer.salesforce.com/docs/component-library/bundle/lightning:navigation/documentation
<lightning:navigation aura:id="navService"/> var navService = component.find("navService"); // Uses the pageReference definition in the init handler var pageReference = { type: "standard__component", attributes: { componentName: "Your Component Name", },state: { c__recordName: Any attribute which you want to pass, c__sc : Any attribute which you want to pass } }; event.preventDefault(); navService.navigate(pageReference); Write the below code in init of the component to which you want to navigate
var pageReference = component.get("v.pageReference"); var recordId =(pageReference.state.c__sc); var recordName = (pageReference.state.c__recordName); console.log('recordId'+recordId+'recordName'+recordName); Hope this will help you out.
Thanks