A hosted app is an Open Web App that has all of its resources (HTML, CSS, JavaScript, app manifest and so on) stored on a Web server. This article provides an introduction to hosted apps and links to everything you need to know about hosted apps from a developer standpoint.
A hosted Open Web App delivers all its content from a Web server, in the same way as a conventional Web site, along with an app manifest in the app's root directory. The app manifest provides details about the app such as its description, icons used to identify the installed app and so on. The details in the app manifest are then used to install the app to Firefox OS devices, Android devices and desktops. Once installed the app loads its content dynamically from the hosting Web Server, and is able to access other resources on the Web, such as a database on a Web server.
Within the Firefox OS security model, hosted apps are defined as web apps. This means they are unable to make use of privileged and internal (certified) APIs : to be able to make use of these APIs the app must be delivered as a Packaged App.
Note: Firefox Marketplace supports paid hosted apps for Firefox OS only and free hosted apps for Firefox OS, Firefox for Android and Firefox for Desktop. Support for paid apps on all platforms is under development.
Options for hosting your app
Where you host the app is up to you. If you haven't chosen a hosting solution, this section describes a couple of commonly used options worth considering.
GitHub
If the content of your Open Web App is static (HTML/CSS/JavaScript, but no server-side processing), GitHub Pages is a solid hosting option. It'll serve your manifest with the correct MIME type if you give it a .webapp
extension.
Generic hosting solutions
For dynamic Open Web Apps, those requiring server-side processing, you can use any generic hosting option (such as a Web server you may already own or have access to). You'll need to ensure the Web server offers the right capabilities. A number of hosting provider offer Web servers that are already tailored to the needs of hosted apps, such as Heroku. Google App Engine or Amazon App Hosting.
Note: Installable open web apps used to have a "single app per origin" security policy, but this was lifted as of Firefox 34/Firefox OS 2.1 (read this FAQ entry for more information). If you still need to support older versions, consider hosting different apps (e.g. a test and live version) at separate origins; one strategy is to create different subdomains for your apps, or you could test it using WebIDE. See the FAQs about apps manifests for more information on origins.
Testing hosted apps
To install a hosted app into a Firefox OS Simulator or onto a device for testing purposes, see Using the App Manager. Alternatively, you can install it on to a device from a Web server by following the steps described in Publishing apps yourself.
Publishing hosted apps
You have two options for publishing hosted apps: on Firefox Marketplace or self-publishing.
Publishing on Firefox Marketplace
The process for submitting a hosted app to Firefox Marketplace is described in the App Publishing section.
When you submit your hosted app, the Marketplace generates a new manifest called the mini-manifest that is based on the app manifest on your hosted app's Web server. When a user installs your app, the mini-manifest is passed to the Apps.install()
function to install the app. The mini-manifest exists for installation and update purposes and isn't used when your app runs.
Publishing yourself
It's possible to publish hosted apps outside Firefox Marketplace, on your own web server. Details are provided in Publishing apps yourself.
Updating hosted apps
Updating of hosted apps happens in two ways:
- changes made on the app's Web server are presented to users the next time they run the app.
- changes to device content controlled by the mini-manifest, such as the app's icon or name, are updated when a new version of the app is submitted to Firefox Marketplace.
For information on updating apps in Firefox Marketplace, see Updating apps. For self-published apps see Publishing apps yourself.