Lightning Out is a powerful feature where you can take your components built inside SFDC to the external system .The Program is under BETA currently .
I have been building lightning components since last year and this year more than half of my time I have been working with lightning components .In fact this year in one of the community led conferences,SEDreamin in Atalanta ,I along with one my colleague architect at CodeScience INC got opportunity to present on lightning components .
If you are interested on slides ,we have the slides on the slideshare and also the code on the github repo .
So in this post ,we will take one of those lightning components to outside salesforce system .We will be pushing this components to heroku .The Heroku app build will be using Node JS .So this article assumes you have knowledge on NodeJS.
2.A free Heroku account .You can install Heroku toolbelt depending on your operating system
3.We are using express and ejs npm package .Using Express and EJS you can build node applications super fast with minimal effort .Ejs has an awesome templating mechanism with excellent support for javascript
Salesforce Configuration
This is a security feature again and found in security controls
Lets take a look at the app.js file which triggers the flow
Here are the key highlight from the code
The key points to look for
1.Observe how simple it is to write four lines of code to inject the lightning component into the page
2.The EJS template engine makes our life lot simpler to inject variables .
The entire code is in my github repo if you want to take a peek .
Lets watch the video of the component running outside SFDC
Please let me know the feedback on this post via twitter or mail . Happy Hacking :)
I have been building lightning components since last year and this year more than half of my time I have been working with lightning components .In fact this year in one of the community led conferences,SEDreamin in Atalanta ,I along with one my colleague architect at CodeScience INC got opportunity to present on lightning components .
If you are interested on slides ,we have the slides on the slideshare and also the code on the github repo .
So in this post ,we will take one of those lightning components to outside salesforce system .We will be pushing this components to heroku .The Heroku app build will be using Node JS .So this article assumes you have knowledge on NodeJS.
Libraries Used
1.nforce - This is a utility that provides ability to obtain access token via oauth (web server flow mechanism)2.A free Heroku account .You can install Heroku toolbelt depending on your operating system
3.We are using express and ejs npm package .Using Express and EJS you can build node applications super fast with minimal effort .Ejs has an awesome templating mechanism with excellent support for javascript
Salesforce Configuration
1.Create a simple Connected App
2.Create a CORS record for your heroku domain
This is a security feature again and found in security controls
Lets take a look at the app.js file which triggers the flow
Here are the key highlight from the code
- We use the nforce library to request for the oauth token
- We store the oauth token using app local variables so that we can retrieve this in our templates
The key points to look for
1.Observe how simple it is to write four lines of code to inject the lightning component into the page
2.The EJS template engine makes our life lot simpler to inject variables .
The entire code is in my github repo if you want to take a peek .
Lets watch the video of the component running outside SFDC
Lightning Out from Mohith Kumar Shrivastava on Vimeo.
Please let me know the feedback on this post via twitter or mail . Happy Hacking :)