Use LWC as Local Actions for Faster JS Code Inside Screen Flows
Introduction
Ever wished your Salesforce Flow Builder screen flows could run JavaScript instantly — without waiting for a server round-trip? Well, now they can. With the Salesforce Winter ’26 release, you can embed Lightning Web Components (LWC) as local actions in screen flows — meaning client-side logic, better UX, less latency.
Table of Contents
- What Are LWC Local Actions in Screen Flows?
- Why This Feature Matters
- How It Works: Step-By-Step Guide
- Frequently Asked Questions (FAQs)
- Conclusion & Next Steps
What Are LWC Local Actions in Screen Flows?
A quick definition:
- A screen flow is a flow type that shows UI screens to the user (collects input, shows data).
- A local action is a piece of logic executed on the client/browser rather than sending a request to the server.
- Using an LWC as a local action means you build an LWC component that implements a special “invoke” method, mark it for “lightning__FlowAction” target, then call it from your flow as a Core Action.
- So: the flow hits this action → the JS in the browser runs instantly → then flow moves on. No Apex round-trip required.
This opens up possibilities for lightweight logic, UI enhancements, redirection, or small API calls.
It’s supported only in screen flows (because you need browser context) and in Lightning runtime.
Why This Feature Matters
Here are key reasons why this is a big deal:
- Performance & UX improvement: Because logic executes on the client, you avoid server latency. For example, showing a modal or toast immediately via JS rather than calling Apex.
- Bridging declarative + code: Previously, flows (declarative) had limited UI-capabilities and needed Apex for complex logic. With LWC local actions you keep flow’s ease and add code flexibility.
- Reusability & modularity: You can build an LWC local action once (e.g., “ShowModalAction”) and reuse it in many flows.
- Better for client-side tasks: Tasks like open a URL, show a toast, basic filtering, or validate fields can run in browser. The official doc says: “get data from third‐party systems without going through the Salesforce server, or open a URL in another browser tab.”
- Reduced Apex / backend overhead: Use flow + local action for tasks that don’t need database changes, saving development effort.
How It Works: Step-By-Step Guide
Sample Use Case
Let’s consider a practical use case to showcase how Lightning Web Components (LWC) as Local Actions in Screen Flows can enhance user experience. Imagine a flow where users enter their name, select a region, and choose a plan from a dropdown. However, not all plans are available in every region — for instance, the “Premium” plan might not be offered in the “APAC” region
When a user selects an invalid combination, the LWC instantly triggers a toast message within the flow screen, notifying them of the restriction — without any server roundtrip.
1. Create the LWC component
JS Code
import { LightningElement,api } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
export default class LwcFlowActionSample extends LightningElement {
@api title;
@api message;
@api async invoke() {
this.dispatchEvent(
new ShowToastEvent({
title: this.title,
message: this.message,
variant: 'warning',
mode: 'dismissable'
})
);
}
}
Meta.xml Code
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>65.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__FlowAction</target>
</targets>
<targetConfigs>
<targetConfig targets="lightning__FlowAction">
<property name="title" type="String" label="Toast title" role="inputOnly" />
<property name="message" type="String" label="Toast message" role="inputOnly" />
</targetConfig>
</targetConfigs>
</LightningComponentBundle>
2. Create a flow

We created a Screen Flow named ScreenFlowLocalAction. Start with a screen which accepts three values
- Name (Text Field)
- Region (Picklist)
- Plan (Pisklist)

Next, below the screen element add the decision element, which validates the right combination for Region and Plan
In our use-case we will add a check to make sure APAC regions cannot avail Platinum plan.

Then, in the invalid branch of the decision element we will add an Action element now and search for our LWC Component that we just created.
As you can also see in the screenshot, you also have the option to populate the target properties mentioned in the meta.xml file of the lwc component.
After the action you can then add another Screen element or any other block you want.
3. Debug and Test
You can now select APAC for region and Platinum from plan picklist, then click on Save. This should show the error message in the toast notification.

FAQ
Q1. Can I use an LWC local action in an autolaunched flow (no screen)?
A1. No — local action LWCs require browser context, so they work only in screen flows (where there are UI screens). Salesforce Developers
Q2. Can the LWC local action send data back to the flow (output variables)?
A2. At the moment, there are limitations. For example, blogs mention this “gotcha” where they couldn’t pass a confirmation boolean back. bobbuzzard.blogspot.com You may need workarounds (e.g., store data in custom object and get by flow, or embed logic differently).
Q3. Does using LWC local action mean I don’t need Apex at all?
A3. Not necessarily. If your logic involves database writes, complex business logic, or secure API calls (with secrets), Apex is still appropriate. Local action is ideal for lighter client tasks.
Q4. Are there any security concerns I should know about?
A4. Yes. Because the logic executes in the browser, you must ensure you’re not exposing sensitive data via properties. Also consider CSP/trusted sites if doing external calls. Use minimal privileges and input validation.
Q5. How do I decide between using Screen Flow alone vs adding an LWC local action?
A5. Use Screen Flow alone when your process is straightforward and uses standard screens/components. Add LWC local action when you need immediate client logic (modal, redirect, local filter) that would otherwise require Apex or external call.
Q6. Will this feature work in Experience Cloud (sites) or mobile?
A6. Generally yes for screen flows in Lightning runtime; but test in context of Experience Cloud pages and mobile browsers to ensure client behavior (pop-ups, modals) works.
Conclusion
You now know how leveraging Lightning Web Components (LWC) as local actions inside screen flows can elevate your Salesforce user-experiences: less server latency, richer UI, and smoother client logic.
Key takeaways:
- This feature bridges declarative flows and custom code elegantly.
- Ideal for client-side tasks: modals, toasts, filtering, redirection, lightweight APIs.
- Still needs good governance: keep logic appropriate, guard security, test across environments.
- Think of this as augmenting your flows — not replacing them or replacing Apex entirely.
Ready to give it a try? Pick a screen flow in your org, identify a place where you’d like a better client experience (for example: confirmation modal before deletion, or redirect after finish), build a simple LWC local action for it, test it in sandbox, and share the results.
👉 Comment below: Which use case will you try first?
👉 Share this blog if you found it useful.
👉 Subscribe to get updates on the latest Salesforce flow & LWC best practices.
Happy building!