Creating your own store

The Mozilla apps project platform provides features in the Web browser that allow Web sites to be recognized as "web apps": rich, interactive experiences, represented by icons, which can be installed and synchronized across devices. You can use this functionality to collect groups of published apps together into directories and stores, and this article explains how.

Integration with the browser

The app platform provides the navigator.mozApps JavaScript object, which a store uses to communicate with the browser.

A Web app is identified by its domain; each domain may contain exactly one app. As a directory or store, you can use the App Installation and Management APIs to prompt the browser to install an app by invoking the apps.install method, providing the URL of the application's manifest and whatever optional installation metadata you require. This metadata can be accessed by application developers to check back with you for purchase confirmation, single sign-on, or other services.

Using getInstalled()

The navigator.mozApps.getInstalled() method allows you to get a list of the apps installed in the current user agent by your domain. Note that you will not see apps installed by other domains, only the ones that you put there.

You can use this method to determine whether the user's installed apps match your expectations, or to implement a "resync" feature if the user signs into your site from a new profile.

Hosting or not?

There is no requirement for a store or directory to host the apps that it describes. The store can simply invoke apps.install with the site's manifest URL.

For apps that do not have a server logic component (that is, which are implemented entirely in client-side JavaScript, HTML, and CSS), you may want to implement a hosting feature. To do this, you need to assign a different domain name to each app and implement server logic to serve the app manifest for each of them.

If you are hosting the app logic yourself, you can easily maintain a session with the user to track preferences, proof-of-purchase, or other additional services. If you are providing services to a remote website, you will need to do some additional work to support a distributed authentication system.

Note: The Firefox Marketplace API contains functionality to allow you to populate your own app store quickly, with the minimum of effort.

 

Document Tags and Contributors

Last updated by: chrisdavidmills,