Use Components Outside Salesforce with Lightning Out (Beta)

We recommend using Lightning Out 2.0 instead of Lightning Out (beta). Lightning Out 2.0 is a new generally available feature that completely replaces–and isn’t an extension of–Lightning Out (beta), which is still subject to Beta Service Terms. See How Lightning Out 2.0 Compares to Lightning Out (Beta).

To run components outside of Salesforce servers, use a Lightning Out (beta) app, a special type of standalone Aura app. Whether it’s a Node.js app running on Heroku or a department server inside the firewall, add your components as dependencies to the Lightning Out (beta) app. Then run the Lightning Out (beta) app wherever your users are.

This feature is a Beta Service. Customer may opt to try such Beta Service in its sole discretion. Any use of the Beta Service is subject to the applicable Beta Services Terms provided at Agreements and Terms.

Developing Lightning web components that you can deploy anywhere is generally the same as developing them to run within Salesforce. Everything that you know about component development still applies. The difference is how you embed your app in the remote web container, or origin server.

To configure your Lightning Out (beta) app, include the Lightning Out (beta) JavaScript library in the page on the origin server. Then add markup that loads your Lightning Out (beta) app and its components. Your Lightning Out (beta) app initializes over a secure connection and is inserted into the DOM of the page. Then your component code takes over and runs the show.

This approach is different from embedding an app using an iframe. Components running via Lightning Out (beta) are full citizens on the page. If you choose to, you can enable interaction between your standalone Lightning Out (beta) app and the page or app you’ve embedded it in. This interaction is handled using Lightning events.

In addition to some straightforward markup, there’s a modest amount of setup and preparation within Salesforce to enable the secure connection between Salesforce and the origin server. And, because the origin server is hosting the app, you need to manage authentication with your own code.

This setup process is similar to what you’d do for an application that connects to Salesforce using the Lightning Platform REST API, and you should expect it to require an equivalent amount of work.

See Also