Getting started with making apps

Web apps are apps built using standard Web technologies. They work in any modern Web browser, and can be developed using your favorite tools.  Some characteristics that distinguish Web apps from websites: Apps are installed by a user, they are self-contained and don't always require the chrome of a browser window, and they can be built to run offline. Gmail, Twitter, and Etherpad are Web apps. 

The Open Web apps project proposes some small additions to existing sites to turn them into apps that run in a rich, fun, and powerful computing environment. These apps run on desktop browsers and mobile devices, and are easier for a user to discover and launch than Web sites. They have access to a growing set of novel features, such as synchronizing across all of a user's devices.

Before you start

If you are a first time developer looking to write web apps then you may want to verify the implementation state of the API.

Just a reminder, Firefox Nightly for Linux still does not support apps!

Publishing the app

The only thing you have to do to create a Web app from a Web site is to add an app manifest. This is a JSON file that describes your app, including its name, its icons, and a human-readable description.

The manifest must be hosted from the same domain as your website, and must be served with a Content-Type of application/x-web-app-manifest+json (Note: this is currently not enforced by Firefox, but it is necessary for the Marketplace). For full details about the manifest refer to the documentation, and to help get started you can try out the online manifest checker.

Same origin policy

It's important to note that each app should be hosted from its own domain. Different apps should not share the same domain. An acceptable solution is to host each app from a different subdomain, for example. See FAQs about apps manifests for more information on origins.

Checking whether the app is installed

When a Web browser loads the app's page, the page needs to handle the case that the user doesn't have the app installed. You can check whether the app is installed by calling getSelf(), like this:

var request = navigator.mozApps.getSelf();
request.onsuccess = function() {
  if (request.result) {
    // we're installed
  } else {
    // not installed
request.onerror = function() {
  alert('Error checking installation status: ' + this.error.message);

Installing the app

You can distribute your app directly from your site. It's also a good idea to test installing from your site, just to make sure your manifest validates, before you submit it to the Mozilla Marketplace.

Just construct a button or link that invokes this JavaScript:

var request = navigator.mozApps.install("");
request.onsuccess = function() {
  // great - display a message, or redirect to a launch page
request.onerror = function() {
  // whoops - has details

Invoking navigator.mozApps.install() causes the browser to load the manifest and ask the user whether to install the application. If the user approves the installation, the app is installed into the browser.

The second parameter is an install_data argument to  navigator.mozApps.install(), to persist some information into the user's installed-applications data store. This information can be synchronized to their other devices, and can be retrieved by your application using the getSelf() call (see Checking whether the app is installed). For example:

        user_id: "some_user"

Promoting the app

Mozilla is building an app marketplace that takes care of discovery, reviews, ratings, and billing, using an open infrastructure that can be used by other third parties to create their own stores. But you're not required to list your app in a store.

If you want people to pay for your app, Marketplace payments.

The Mozilla App Marketplace is expected to be available soon. You can also sign up for the Apps Developer newsletter to get news about the progress of the Mozilla App Marketplace, as well as tips and advice on creating apps.

Running offline and using advanced device APIs

Modern Web browsers have added a lot of great features to let your application run offline or access device capabilities. Here are some useful links:

Storing data locally

The localStorage API provides a key-value store of persistent data that you can use to keep track of user data between visits to your app. If the user has a modern browser, such as Firefox 4 or later, or Google Chrome, you can also use IndexedDB, a structured, high-performance client-side datastore.

If you have data that should be shared between instances of your app across all devices that a user uses, then you should use the install_data parameter to the install() function, as described above.


Some examples of open web apps:

Tags (2)

Edit tags

Attachments (0)


Attach file