Open Web Applications are just websites. They are built using standard web technologies that run in any web browser, and can be developed using your favorite tools.
The Mozilla Labs Open Web Applications project proposes some small additions to existing sites that turn them into applications which run in a rich, fun, and powerful computing environment. These applications run on desktop browsers and mobile devices, and are easier for a user to discover and launch. They have access to a growing set of novel features, such as synchronizing across all of a users' devices.
Describing Your Application
The only thing you have to do to create a web application from a web site is to add an application manifest. This is a JSON file that describes your application, including its name, its icons, and its 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. For full details about the manifest refer to the documentation, and to help get started you can try out the online manifest checker.
Publishing Your Application
navigator.apps.install() will cause the browser to load your manifest and ask the user whether they want to install your application. If they approve the installation, your app will be installed into their browser!
You may optionally provide an
install_data attribute to install, to persist some information into the user's installed-applications data store. This information will be synchronized to their other devices, and can be retrieved by your application using the
amInstalled() call (see next section). For example:
Determining Whether Your App Is Installed
When a web browser loads your application page, you should be ready to handle the case that the user doesn't have the application installed. You can check whether the application is installed by calling
amInstalled(), like this:
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. In Firefox 4 and other new browsers, you can also use IndexedDB, a structured, high-performance client-side datastore.
If you have data that should be shared between instances of your application across all a user's devices, you should use the
install_data option to the
install() function, as described above.
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:
- Running offline: details and demos that show how to use the HTML5 AppCache
- Online and Offline Events: detecting when the device changes between online and offline states
- Using audio and video in your application
- Drawing Graphics with Canvas
- Drawing 3D Graphics with WebGL
- Using Content-Editable to create full and fast rich-text editors in your app
- Using Files from Web Applications with the HTML5 File API
- Using Drag and Drop to drag items between and within web applications
- Detecting Device Orientation