We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

Writing a web app for B2G

Firefox OS apps are just Web apps written with HTML, CSS, and JavaScript. You publish them on the Web like you would publish any other Web site. In order to make the Web site installable as a Web app on the device, you just have to garnish them with a manifest and hook up an install button as explained below.

The following topics are recommended starting points:

Of course, feel free to dive even further into Open Web Apps!

Installing the Web app

With the app and manifest published on the Web, you need to make Gecko aware of it. At install time, Gecko looks up the manifest and adds the necessary entries to the home screen, etc.

To install an app, call the navigator.mozApps.install API. Here's example for an install button that you could embed in your app when you self-host your app:

<button id="install">
  Install this awesome app on your homescreen!
  function install(ev) {
    // define the manifest URL
    var manifest_url = "http://my.webapp.com/manifest.webapp";
    // install the app
    var myapp = navigator.mozApps.install(manifest_url);
    myapp.onsuccess = function(data) {
      // App is installed, remove button
    myapp.onerror = function() {
      // App wasn't installed, info is in this.error.name
      console.log('Install failed, error: ' + this.error.name);
  // get a reference to the button and call install() on click
  var button = document.getElementById('install');
  button.addEventListener('click', install, false);

Note: the Install button could also be in an app market, such as the Firefox Marketplace, but it's often very handy to have an "Install as web app" button on the main page of your site.

Now visit your web site in the Firefox OS browser app and tap the install button.

Document Tags and Contributors

Last updated by: Sheppy,