January 30, 2017 by LanceShi
1.1 Write a Hello world lightning app
Once you setup your environment, we are ready to write our first lightning app.
Lightning app is also called lightning standalone app. It is a single page application. In short, it can help displaying content on a web page.
Now we can start building our first lightning app.
In your developer console, click File > New > Lightning Application. In the name field, type in HelloWorldApp. Then type in the following code and save.
<aura:application> Hello World! </aura:application>
You can run your code by navigating to this url: https://[YourDomainName].lightning.force.com/c/HelloWorldApp.app . I assume you are not using any namespace prefix. Otherwise, change c into your namespace.
A little bit explanation
It is pretty easy, huh? Just like Visualforce page, lightning component/app has its own set of tags. For a lightning app, it always starts and ends with an aura:application.
And this page displays Hello World in the page. You can put almost any html tags into lightning app. Just like normal html page.
But one thing worth to mention is, lightning app doesn’t play the same role as Visualforce pages. Actually, lightning component does. This might be confusing because it seems that both lightning app and Visualforce page can be opened via typing a url, but lightning component can’t. But the reason behind that is Salesforce classic is a page-centric app, so everything is basically an independent web page. And that’s why Visualforce pages played such an important role.
Lightning experience, however, is a big single page application. Itself is only one giant web page. So everything running inside it, is a component. Thus, lightning app is a standalone app which runs in parallel with Salesforce’s major app. And that is why lightning component is playing the existing role of Visualforce pages, instead of lightning app.
But even though, the most effective way to test a lightning component during development currently is to embed that inside a lightning app. In the next section, we will be talking about how to write your first lightning component.