Running A Salesforce Aura App Locally And On Heroku
Aura framework is an open-source UI web framework from Salesforce. Lightning Components framework is built on top of Aura framework. In this blog you'll learn how to install an Aura framework based Tic-tac-toe app on Heroku.
Aura is an open-source UI framework for developing dynamic web apps for mobile and desktop devices. Lightning Components framework is built on top of Aura. The big difference between Aura and Lightning Components is that Lightning components runs on Apex, whereas Aura runs on Java. Another difference is that Lightning Components have Salesforce specific components that are used inside Salesforce and in S1 Mobile app.
One nice thing about Aura is that you can build custom enterprise grade apps locally and run it in your own datacenter or on Heroku. In addition, you can also use Aura to understand the internals of how the framework works. In this blog I’ll show you how to run an Aura app and deploy it on Heroku and also on local machine.
Tic-Tac-Toe Aura App
As an example, I took the Tic-tac-toe lightning app and converted it into Aura. Since this app doesn’t use server, all I had to do was to simply copy all the components and change the namespace.
In Eclipse, the app looks like below:
Just like any Java web apps, we need to store components inside WEB-INF folder. Then you first start off by creating a namespace folder and then keep all your components inside that folder. And finally every component bundle has it’s own folder and a set of files as shown below.
Deploying Via Heroku Button
Click on the Heroku Button below to install it right from this blog post.
- Enter App name (optional)
- Press “Deploy for Free” button
- Press “View” button to see the app
Running It Locally
Make sure you have Maven and JDK 7 installed. Aura needs JDK 7 and won’t work in JDK 8.
git clone https://github.com/rajaraodv/tictactoe.git
mvn clean install
You can open the project in Eclipse.
File > Import > Maven > Existing Maven Projects and point to the root tictactoe folder
Right click on pom.xml and select “maven install”
Right click on pom.xml and select “Run Configuration” and enter “jetty:run” as target
Deploying a New Aura App On Heroku
Aura framework needs JDK 1.7 and Jetty to run. So in order to run it on Heroku, you need to configure both.
- To configure JDK 1.7, simply create a system.properties file in the root folder. And add java.runtime.version=1.7
- To configure Jetty, first you need to add the jetty-runner plugin to the maven file. This downloads the Jetty-runner to run the app.
- And finally, create a Procfile in the root directory with the following value:
web: java $JAVA_OPTS -jar target/dependency/jetty-runner.jar --port $PORT target/*.war
All it is saying is that we need a “web” process and run our app (war file in target folder) using jetty-runner.
To manage multiple JDK on your machine, you may want to set environment like below and simply enter setJdk7 or setJdk8 when you want to change the JDK.
alias setJdk6='export JAVA_HOME=$(/usr/libexec/java_home -v 1.6)'
alias setJdk7='export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)'
alias setJdk8='export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)'
- Getting Started With Java On Heroku
- Deploy a Java app that runs With Jetty-Runner
- Aura OSS guide [PDF]
If you have any questions, please feel free to add it in the comment below or contact me on Twitter at: @rajaraodv