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
Marketing Marketing 27Marketing Marketing 27 

Launch LWC component inside Aura Component without redirecting to a new page?

I have a lightning web component that helps users make a record of a custom object by dynamically autofilling a lot of the fields.

I want to override the New button so that they can make the record from the related list on the opportunity page however I know to do that I have to embed it in an Aura Component. 

The main problem with this is that I don't want the aura component to redirect them to a new page. I want it to keep opening up the new record window for the custom object ON the opportunity page.

How can I embed my LWC in an Aura component that will stay on the same page when it is triggered?
AshwiniAshwini (Salesforce Developers) 
Hi @Marketing Marketing 27,

It seems you have a specific implementation request that requires a solution where you can embed a Lightning Web Component (LWC) inside an Aura Component while ensuring users remain on the Opportunity page. Here's a high-level overview:
  • To launch an LWC inside an Aura Component without redirecting to a new page, use Lightning Component events for communication between them. Create an Aura Component to act as the container for the LWC and inside the Aura Component markup, include your LWC using the <c:yourLWC> syntax.
  •  In your Aura Component JavaScript controller, handle events that are fired from the LWC. For example, you can create a custom event in your LWC and handle it in the Aura Component.
  •  You can override the New button with a Lightning Component Quick Action on the Opportunity object. In this Quick Action and add the Lightning Component Quick Action to the Opportunity Lightning Record Page layout. 
  • When users click the Quick Action, it will launch your Aura Component, which embeds your LWC. The LWC can then communicate with the Aura Component using events to perform actions on the same page without redirection. 
Related:
https://www.brcline.com/blog/using-lightning-web-components-inside-aura-components#:~:text=To%20use%20an%20Aura%20Component,dom%3D%E2%80%9Dmanual%E2%80%9D%20directive. 
https://salesforcecodes.blogspot.com/2020/01/how-to-use-lightning-web-componentslwc.html
Thanks.