A flow screen component can control navigation programmatically by dispatching navigation events from the lightning/flowSupport module. You can advance to the next screen, go back, pause the flow, or finish it, and you can check which actions are available before firing an event.
Navigation Events
Import navigation events from lightning/flowSupport.
Event
Description
FlowNavigationNextEvent
Advances to the next screen. If the current screen is the last one, use FlowNavigationFinishEvent.
FlowNavigationBackEvent
Returns to the previous screen.
FlowNavigationPauseEvent
Pauses the flow interview and saves its state for later resumption.
FlowNavigationFinishEvent
Finishes the flow interview and triggers any configured post-flow behavior, such as a redirect URL.
Check Which Actions Are Available
Not every navigation action is available on every screen. For example, the Back action isn’t available if the current screen is the first screen, and the Pause action is available only in flows where saving is enabled. Before you fire a navigation event, check whether the corresponding action is available.
Flow Builder passes a list of available actions to your component through the availableActions property. Declare it as an @api property in your component’s JavaScript file.
When your component provides its own navigation buttons, hide the flow screen’s built-in footer so that the screen has only one set of navigation controls. In Flow Builder, open the screen element that contains your component. In the Configure Footer section, disable Show Footer.
Navigation Event Guidelines
Follow these guidelines when using navigation events.
Fire navigation events in event handlers or in methods that an event handler invokes.
Don’t fire navigation events outside of event handlers. Doing so leads to a poor user experience.
Don’t fire navigation events in lifecycle hooks such as connectedCallback or renderedCallback.
Avoid firing FlowAttributeChangeEvent and a navigation event at the same time. There’s no guarantee that the component has rendered updated values before navigation begins, which can cause race conditions.
To improve flow performance, consider these best practices.
Don’t use a dummy screen to perform navigation. It leads to poor flow performance.
Don’t include code after dispatching a FlowNavigationNextEvent. Navigation moves the user away from the current screen immediately, so any code after the dispatch doesn’t run.
If you encounter a scenario where navigation must be done within the initialization phase of the screen because data isn’t yet available to Flow Decision Nodes, post a request for an upgrade in Idea Exchange.