PWA - Installable apps
PWA is a widely spread web-standard allowing web applications to be installed on local devices. You can read more on MDN Documentation:
Enable PWA
All applications built with Draw are PWA-ready out of the box. You just need a running backend on your environment (learn more why). In details, browsers require a few things to make an web-app installable (learn more):
- a manifest file included with a <link> tag in the head of the HTML
- a service worker installed and registered for the running application with a fetch handler.
This feature is now optional for most browser.
Draw applications automatically ship with the manifest and you can opt-in for the service worker which implements the Cache API to allow offline start of the application.
Requirements
Feature | Requirement |
---|---|
Add a manifest <link> in the HEAD | A backend running on the environment |
A service worker registered with Cache API | offline.enabled: true in the oConfig |
Any backend on the environment is configured with a web-service that delivers the manifest file with some default values. You can customize the manifest. Read on to learn more.
Configuring the PWA
Configuring the PWA is done by setting the right values in the manifest file. As explained above, the content of this manifest is built by the backend of your app. By default, the manifest only contains the minimal required properties for the PWA to work, specifically:
name
: with the name of the UI appshort_name
: with the name of the UI appid
: with the tag of the UI appstart_url
: with the URL to launch the appdisplay
:"standalone"
backgroundColor
:"fff"
icons
: with the Olympe icon
There are a lot more configurable properties, you can learn more on MDN documentation:
Every field are configurable using the oConfig.json
of the node app. You can either configure values for the whole environment or per-app. Any configuration that you set will be merged in this order
- default config (above)
- instance manifest config (
app.manifest.common
) - app manifest config (
app.manifest.<app_tag>
)
Examples
Add the same icon to all apps of the instance
// The # symbol at the beginning of the config key indicates to the config parser that the value of this key should be serialized
{
"#app.manifest.common": {
"icons": [
{
"src": "https://cdn-icons-png.flaticon.com/512/891/891462.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable any"
}
]
}
}
Set the name of a specific app
// The # symbol at the beginning of the config key indicates to the config parser that the value of this key should be serialized
{
"#app.manifest.<app_tag>": {
"name": "Specific Name"
}
}
Set a property not already included in the default manifest
// The # symbol at the beginning of the config key indicates to the config parser that the value of this key should be serialized
{
"#app.manifest.<app_tag>": {
"description": "Awesome application that will help you achieve your dreams.",
"orientation": "landscape-primary"
}
}