How to launch Flows from Your Own Lightning Web Component
Target Persona: Developer
If you’re working in Aura, you can insert the lighting:flow component. This is the same component that you can insert into pages in App Builder. However, Salesforce has not yet made lightning:flow available in LWC. Because LWC does not allow the embedding of Aura components, you can’t just add the lightning:flow component to your LWC. Why isn’t it available yet? lightning:flow is probably the most complex page component and has to be completely rewritten to work in LWC. It’s on the way, but it’s taking time.
The current options for working around this depend on whether you want to execute a visual flow that has screens and requires a user session with a browser, or whether you want to execute a screen-less ‘Autolaunched’ flow.
For Screen Flows
Wrapping lightning:flow and your LWC in an Aura wrapper component, and sending messages from your LWC to control the Flow component. Check it out here.
You can have your component load the Flow by URL. This will either load the Flow into a new tab or a new window, or you can have it overwrite your existing page (and your existing LWC).
For Autolaunched Flows
If the Flow is an Autolaunched flow (and thus doesn’t have screens) you can dynamically launch it from your LWC code by using an Apex call to the Flow invocation point.
Flows can be launched from platform events as of Summer ’20, so you can have your LWC fire a platform event. This also only works with screen-less flows.