Uniquely identifying PWAs with the web app manifest id property
When the user installs your PWA, the browser needs a way to uniquely identify the PWA. But, until recently, the web app manifest spec didn't explicitly define a way to uniquely identify a PWA, leaving browsers to decide and leading to different implementations. In some browsers, the start_url
is used, while in others, the path to the manifest file is used, making it impossible to update either of those fields.
To solve this issue, there's a new optional id
property in the web app manifest spec, that allows you to explicitly define the identifier used for your PWA. Adding the id
property to the manifest removes the dependency on the start_url
or the location of the manifest, and makes it possible for them to be updated in the future.
id
property do?
What does the The id
property represents the identity of the PWA to the browser. When the browser sees a manifest that does not have an identity that matches an already installed PWA, it will treat it as a new PWA, even if it is served from the same URL as another PWA. But if it sees a manifest with an identity that matches the already installed PWA, it will treat that as the installed PWA.
Browser support
Support for the id
property is expected to land in desktop Chromium-based browsers starting with version 96. Support for mobile (which currently uses the manifest url as the unique id) should land in the first half of 2022.
What should I do today?
Today, there is nothing you need to do, and nothing will break if you don't add an id
to your web app manifest (as long as the start_url
and the manifest path remains the same). To future-proof your PWA, you can add an id
property to your web app manifest.
id
?
How do I determine and set my The safest, and the most accurate, way to determine the id
for a PWA is to check the value calculated by Chrome.
- Using Chrome 96 or higher (currently available as Chrome Canary), open the Manifest pane of the Application panel in DevTools.
- Hover your mouse over the
(!)
icon next to the App Id property. The(!)
tooltip icon will only appear when theid
is not specified in the web app manifest file. - Note the
id
value shown in the tool tip (see screenshot below). - Add an
id
property to the web app manifest using theid
value shown in the tooltip.
{
...
id: "/?homescreen=1",
start_url: "/?homescreen=1",
...
}
In some cases, the id
may not be the same as the start_url
, therefore it is always best to verify the actual id
value generated by Chrome in DevTools.
id
?
What if I don't set an Don't worry, nothing will break. Starting in Chrome 96 on desktop, the browser will generate an id
if there is not one in the manifest. On desktop, it will be calculated based on the start_url
in the web app manifest.
In the future, adding an id
to the web app manifest will make it possible to change the start_url
and the manifest path, because the browser will identify the PWA based on the specified id
, rather than the start_url
or manifest path.
How do I test this today?
To test the behaviour before Chrome 96 is available as stable, follow these steps:
- Using Chrome 96 or later (currently Chrome Canary), enable the
#enable-desktop-pwas-manifest-id
flag, then restart the browser. - Install the PWA.
- Open
about://web-app-internals/
and check theunhashed_app_id
andstart_url
property for the installed PWA. - Add an
id
property to your web app manifest following the steps in How do I determine and set myid
above. - Restart the browser using
chrome://restart
, launch the PWA fromabout://apps
, then close the PWA to force the manifest file to refresh. - Open
about://web-app-internals/
and check themanifest_id
property for the installed PWA to verify it hasn't changed. - Change the
start_url
in the web app manifest. - Restart the browser using
chrome://restart
, launch the PWA fromabout://apps
, then close the PWA to force the manifest file to refresh. - Open
about://web-app-internals/
and check thestart_url
property for the installed PWA to verify it has been updated as expected.