With Lightning Out 2.0, a key feature of Lightning Web Runtime (LWR), you can embed Lightning Web Components (LWCs) directly into websites and applications regardless of how they are hosted and served. This lets you bring FinDock Payment Experiences into an existing self-hosted frontend, for example, while still leverage the native payments functionality of FinDock on Salesforce.
You can create custom payment channels, using FinDock’s Flow and LWC solutions as building blocks, configure the digital experience in Salesforce, and use Lightning Out 2.0 to bring it to an external website or application. This is a convenient option when you want to create a customer-facing payment experience outside Salesforce quickly with relatively little development effort.
We take you through the steps to get your Lightning Out 2.0 solution up and running. Many actions need you to republish your Experience Cloud site, but sometimes this is not obvious after you make a change. Keep this in mind and make re-publishing a habit as you work through the steps.
To use Lightning Out 2.0, your external site or app needs to:
- Support iframes
- Use HTTPS
- Allow third-party cookies
In addition, this guide assumes you have already created a digital payment experience, either using Flows or custom LWCs.
If you have an existing Experience Cloud site on LWR, you can reuse that. Otherwise, following the procedure below to create a new site.
- Create a site
Go to Digital Experiences Home and click Create an Experience. Select either the Build Your Own (LWR) template the Lightning Out (LWR) template. If you select the latter, you can skip steps 2 and 3. Follow the steps in Salesforce to build the site with the template.
- Add a Lightning Out page
After the site is built, click Builder. Then, under the Home dropdown menu, click +New Page to add a Standard Page with the preconfigured Lightning Out layout.
- Add a Lightning Out container
On the new Lightning Out page, add the following component:
force:lightningOutLWRContainerThis component, when added to your Experience Cloud site, allows Lightning Out 2.0 to provide guest user access using its Guest User settings. This component is only available in LWR sites. If you don't see it, you might need to toggle on the Show All Components. Save your changes and publish the site.
- Configure site access
Go to the Experience Builder settings. On the General tab, enable Guest users can see and interact with the site without logging in. This allows unauthenticated users to access the site.
- Configure Clickjack protection
Go to the Security & Privacy tab set your desired clickjack protection level. We recommend using Allow framing of site pages on external domains (Good protection).
With that level of protection, you get an additional Trusted Domains for Inline Framing setting. Add there the external website URL/URI that hosts your Lightning Out 2.0 components. In addition, add
https://*.findock.comas a trusted domain. This is required for payment processing through FinDock. - Grant permissions to the Guest User
Assign the following permission sets to the Guest User:
- If you are using a FinDock Labs solution, assign the permission set of the given template, e.g. FinDock Labs Checkout Flow Guest Access or FinDock Labs Donation Flow Guest Access.
- FinDock Core Experience Cloud Run
If you are using Flow in your Lightning Out app, give your Guest User access to that Flow.
With your site ready, you can now prepare Salesforce to use it.
Here we work with the Salesforce Setup to make sure Lightning Out 2.0 components can be reached from external sites.
- Add trusted domain
You need to (also) add your external site as a trusted domain in Salesforce Setup. Go to Session Settings and click Add Domain under Trusted Domains for Inline Frames. Make sure you enter the exact same URL/URI as you did in the Experience Builder settings above.
When you add the domain, select the option IFrame Type = Lightning Out and then save your changes.
- Add external host
From Salesforce Setup, go to Trusted URLs and click New Trusted URL. Add the domain where your external application is hosted. Set CSP Context to All and enable the required CSP directives for the Lightning Out integration (at least allowing script and iframe).
The host application’s CSP must also allow any domains that the embedded Lightning Out 2.0 component needs to frame or navigate to.
The FinDock URL needs to also be one of your trusted URLs. If it is not listed, create another new one for
https://*.findock.com. - Add external site to CORS
From Salesforce Setup, go to CORS and add your external site origin to the Allowed Origins List. If you are using a different origin for development, you need to add that as well to the allowed list.
Under Cross-Origin Resource Sharing (CORS) Policy Settings check Enable CORS for OAuth endpoints.
Lightning Out 2.0 requires cross-domain Salesforce cookies. If Require first-party use of Salesforce cookies is enabled under My Domain > Routing and Policies, disable it.
With Salesforce configured, you can now expose your Lightning Out 2.0 components through external environments.
Lightning Out 2.0 only works with LWC. Any exposed component needs to be an LWC, or referred through an LWC. If you want to expose a Flow to an external website, you have to refer to that Flow from a LWC as well.
- Create container component
Create the LWC that you want to expose on the external website. From the Lightning Out 2.0 perspective, this is a regular Salesforce LWC, you can build it using the same components, Apex controllers, configuration and Salesforce data that you would normally use inside Salesforce.
Flow example
<template> <lightning-flow flow-api-name="Donation_Flow"></lightning-flow> </template>With Flow, remember that you need to provide Guest User access to make the Flow work on the external page.
- Create Lightning Out 2.0 app
From the Salesforce Setup, go to Lightning Out 2.0 App Manager and click New Lightning Out 2.0 App. Give the app a name and select CLWR for the runtime environment.
Click Save and Continue, enable the app, and then click Save.
- Add components to expose
For the app you just created above, select Edit App from the dropdown list to the right. Click the App Components tab and add every LWC, for example,
c-payment-form, that you want to expose through the Lightning Out 2.0 app. These components are exposed to the public and accessible under the Guest User profile of your linked Experience Cloud site.Only add components to the app definition that you want to be exposed. If you include a component that should not be exposed, you might reveal internal data. If the component doesn't exist in the given org instance, you may run into errors or exceptions when using the Experience Cloud site.
If your flow runs in Access All Data mode, the Guest User might get access to internal objects and data. Please keep your authorization model in mind when exposing components.
If you are exposing LWCs such as FinDock payButton and paymentSelector in Flows through Lightning Out 2.0, you need to add them to the Lightning Out app definition as well, respecting the namespaces.

The Lightning Out 2.0 app components setup should look like this:

- Link the Experience Cloud site
In the Lightning Out 2.0 app setup, click Linked Community Site tab. Select the LWR Experience Site created earlier and click Save.
Salesforce uses this site to provide the Guest-User context for the embedded components.
When you hit save your changes, you are redirected to the Experience Cloud site. You can’t save the Lightning Out 2.0 app without confirming the redirect. If you executed all the steps above, you don’t need to do anything with the site.
- Copy-paste generated embed code
The Lightning Out 2.0 app generates the code for the external website. You can find it on the main page of the app. Copy it and paste it into your external page. For example:
<script type="text/javascript" async="" src="https://YOUR-ORG.my.salesforce.com/lightning/lightning.out.latest/index.iife.prod.js"> </script> <lightning-out-application app-id="YOUR_APP_ID" components="c-payment-form"> </lightning-out-application> <c-payment-form></c-payment-form>The script +
lightning-out-application+ component markup belong together as the generated Lightning Out 2.0 embed. Salesforce calls this the host-page integration model. Thecomponentsproperty should only include the outermost component to be presented, not all components defined for the Lightning Out 2.0 app.These few lines of code are all you need to load Lightning Out 2.0 on an external website, connect to your org and load your components.
- Configure redirect
When a payment is initiated from a FinDock component running through Lightning Out 2.0, the redirect to the PSP is time sensitive. Browsers may block the redirect navigation if the PSP response takes too long (5 seconds in the case of Chrome, for example). This is due to the sandboxed iframe context of the component in Lightning Out.
To handle this limit gracefully, should the initial redirect fail, you can add the following snippet to your app configuration (replacing the event origin with your URL instance):
<script type="text/javascript"> window.addEventListener('message', (event) => { if (event.origin !== 'https://YOUR-SALESFORCE-SITE.my.site.com') { return; } if (event.data?.type === 'findock-redirect') { window.location.href = event.data.url; } }); </script>This configuration creates a fallback mechanism that gives the parent of the component the (delayed) redirect message to handle.
These two properties get a separate step because they are easy to miss and are not included in the auto-generated Lightning Out markup. Without them, Lightning Out 2.0 may try to initialize against the wrong site context and fail even when the rest of the configuration is correct.
For the Guest User context with Experience Cloud, we need to manually add these parameters to the generated script.
org-urltells the Lightning Out runtime which Experience Site should provide the Salesforce contextsite-prefixidentifies the correct site path
These parameters go in the lightning-out-application block of the generated embed code:
<lightning-out-application
app-id="{{ $appId }}"
org-url="{{ $orgUrl }}"
site-prefix="{{ $sitePrefix }}"
components="namespace-componentName"
></lightning-out-application>When adding org-url, use the site origin URL, not the URL to the Lightning Out page.
| Correct | Incorrect |
|---|---|
| https://YOUR-SITE.my.site.com | https://YOUR-SITE.my.site.com/lightning-out |
For site-prefix, you can check the prefix from the URL in the table of configured sites (Digital Experiences) in Salesforce Setup.

With the two parameters in place, along with the redirect snippet, the full embed should look something like:
<script
type="text/javascript"
async=""
src="https://YOUR-ORG.my.salesforce.com/lightning/lightning.out.latest/index.iife.prod.js">
</script>
<lightning-out-application
app-id="YOUR_APP_ID"
org-url="https://YOUR-SITE.my.site.com"
site-prefix="donations"
components="c-payment-form">
</lightning-out-application>
<c-payment-form></c-payment-form>
<script type="text/javascript">
window.addEventListener('message', (event) => {
if (event.origin !== 'https://YOUR-SALESFORCE-SITE.my.site.com') {
return;
}
if (event.data?.type === 'findock-redirect') {
window.location.href = event.data.url;
}
});
</script>Even if your site does not have a prefix, you still need to include the parameter (site-prefix="") to make your Lightning Out 2.0 app work.