These three fields decide your app's identity and boundaries. Get them right before launch, because fixing them later affects every user who has already installed your app.
id: who the app is
The id is the app's permanent identity. Browsers and stores use it to recognise "the same app" across updates.
"id": "/"
- It is resolved against your origin, so
"/"becomeshttps://example.com/. - If you leave it out, the browser uses
start_urlas the id. Then, if you ever changestart_url(to add?source=pwa, for example), people get a second, separate app. - Set it on day one and never change it.
If you already shipped without an id, set id to your current start_url exactly. Chrome DevTools > Application > Manifest shows the computed id and suggests the value.
start_url: where it opens
"start_url": "/?source=pwa"
- It must be inside
scope, otherwise the browser ignores the manifest. - A query parameter lets you count launches from the installed app in analytics. It must not change the page content, or your offline cache needs to store that exact URL too.
- Make sure the start page works offline: precache it in the service worker.
scope: where the app ends
"scope": "/"
- Navigations inside the scope stay in the app window.
- Navigations outside it open in the browser, or show a bar with the URL, depending on the platform.
- If you omit it, the scope is the folder that contains
start_url./app/index.htmlgives a scope of/app/.
The service worker has its own, separate scope (the folder it is served from, unless you use the Service-Worker-Allowed header). Keep the two the same.
Patterns
One app for the whole site (most common):
{ "id": "/", "start_url": "/?source=pwa", "scope": "/" }
An app in a sub-folder of a bigger site:
{ "id": "/app/", "start_url": "/app/", "scope": "/app/" }
Several languages, one app: keep one id, let start_url be the language root, and put the language in the scope only if each language should be a separate app.
{ "id": "/", "start_url": "/es/?source=pwa", "scope": "/" }
Several apps on one origin: give each one its own id and its own scope, and make sure their scopes do not overlap.
Check your values with the manifest validator.