Salesforce: Hey, Did You Know?: Can you use Third-Party Libraries in Lightning Components?

One highly sought after feature (among others) in Lightning Components was, being able to use third-party frameworks/libraries in lightning components. When lightning components were released, it was hinted that we will eventually be able to use those libraries. Everyone (or at least I was) was holding their breath to see how it will unfold. Main problem was security. Some frameworks like Angular/React take over entire DOM and rebuild it. But that couldn’t be allowed in lightning components due to data sensitivity.

But the wait is over! Yes, we finally have a way to use these libraries in lightning components. It strikes a nice balance between security and usability.

If you haven’t already guessed then I am talking about “Lightning Container”. You can create an app in HTML, zip it up, store it as a static resource and embed it in your components. The embedded HTML page is loaded in a different DOM (with limited access to the parent DOM) and runs in its own context. But without being able to talk to your component it will be quite useless, won’t it?

Fear not, the Lightning Container Component (lightning:container) is a convenience component that wraps an iframe and provides a simple API to communicate between the iframe container and its content. Following are some of the resources that can get you started:

Let’s start this amazing journey together!!!

Leave a Reply