Third-party Libraries are used by most of the developers nowadays because Third-party libraries provide quick and easy work around that can save you a lot of time and help you avoid some lines and efforts while writing codes.

Third-party libraries usually fall in one of the following categories:

  1. DOM manipulation libraries ( ex. jQuery, etc.)
  2. Specialized Utility Libraries (ex. moment.js, numeral.js, etc)
  3. UI Libraries (ex. Bootstrap, jQuery UI, etc.)
  4. Data Visualization Libraries (ex. D3, Chart.js, Leaflet, etc.)
  5. MVC Frameworks (ex. React, Angular, etc.)

How to use third party libraries in lighting components-

There is a whole lot of powerful features which are provided by the Lightning Framework. In lighting components, Functionalities by your library might not always work.
In lightning component, we need to add these libraries to a static resource, and then we can include the library by using tag <ltng:require>
Upload everything in zip format under static resources. And use them in <ltng:require> tag.


&amp;lt;ltng:require styles="{!$Resource.YourCSSResource}" scripts="{!$Resource.YourJSResource}" afterScriptsLoaded="{!c.afterScriptsLoaded}"/&amp;gt;

afterScriptsLoaded attribute is used to execute some javascript method after the script is loaded.

To include a JavaScript library that you’ve uploaded as a static resource, use a <ltng:require> tag in your .cmp or .app markup.
Using styles attributes, you can include the .css resources into the component or app and be using scripts attribute you can include the javascript resources into the component or page.

Here is an Example of aura component:

&amp;lt;ltng:require styles="{!$Resource.YourCSSResource}" scripts="{!$Resource.YourJSResource}" afterScriptsLoaded="{!c.libLoaded}" /&amp;gt;
&amp;lt;div class='mynamespace'&amp;gt;
&amp;lt;div class="dropdown"&amp;gt;
&amp;lt;ul class="dropdown-menu" role="menu" aria-labelledby="mLabel"&amp;gt;
&amp;lt;li role="presentation"&amp;gt;&amp;lt;a role="menuitem" href=""&amp;gt;Action&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li role="presentation"&amp;gt;&amp;lt;a role="menuitem" href=""&amp;gt;Another action&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;

Class mynamespace, dropdown, dropdown-menu would be defined into the libraries.This is the method of how one can use JS Function which will always execute after loading of the script.

libLoaded: function(component, event, helper) {
alert('ready to go');

Here is the example of JQuery sortable. We have to add the JQuery resource in the page and use functions to perform the functionality.


You can use bootstrap classes for CSS. After adding the Bootstrap resource, you need to add the class on the element.

Steps to include bootstrap in your lightning:

  • Download the optimized Bootstrap package.
  • Unzip that package and go to Setup > Build > Develop > Static Resources and click New.
  • Specify bootstrap as the Name, then click the Choose File button, and select the bootstrap.css in the dist/CSS directory of the unzipped bootstrap folder.

After adding bootstrap in static resources, you can use the classes of bootstrap to your component elements.

&amp;lt;div class="navbar-header"&amp;gt;
&amp;lt;a href="#" class="navbar-brand"&amp;gt;Accounts Details&amp;lt;/a&amp;gt;

So, this is how you can implements the standard UI by third-party libraries with your lightning components.