Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

Embed a Flow in a Custom Aura Component

Once you embed a flow in an Aura component, use JavaScript and Apex code to configure the flow at run time. For example, pass values into the flow or to control what happens when the flow finishes. lightning:flow supports only screen flows and autolaunched flows.

A flow is an application, built with Flow Builder, that collects, updates, edits, and creates Salesforce information.

To embed a flow in your Aura component, add the <lightning:flow> component to it.

1<aura:component>
2    <aura:handler name="init" value="{!this}" action="{!c.init}" />
3    <lightning:flow aura:id="flowData" />
4</aura:component>
1({
2    init : function (component) {
3        // Find the component whose aura:id is "flowData"
4        var flow = component.find("flowData");
5        // In that component, start your flow. Reference the flow's API Name.
6        flow.startFlow("myFlow");
7    },
8})

When a page loads that includes a flow component, such as Lightning App Builder or an active Lightning page, the flow runs. Make sure that the flow doesn’t perform any actions – such as create or delete records – before the first screen.

Note