id
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
The id manifest member is used to specify a unique identifier for your web application.
Syntax
/* Absolute URL */
"id": "https://example.com/myapp"
/* Relative URL */
"id": "myapp/v2"
/* URL with query parameters */
"id": "myapp?version=2&mode=trial"
Values
id-
A string that takes the form of a URL. The URL must be same-origin with the
start_urlof your web app. Ifidis a relative URL, it is resolved using the origin ofstart_url. Any fragment in theidis always ignored. Ifidis not specified or the value is invalid in any way (such as not a string, not a valid URL, not same-origin withstart_url), thestart_urlvalue is used.
Description
The id manifest member serves as a unique identifier for your web app. It allows browsers to distinguish between different applications:
- When a browser comes across an app manifest with an
idthat does not correspond to an already installed application, it treats that manifest as a description of a distinct application, even if it is served from the same URL as another application. - When a browser comes across an app manifest with an
idthat matches the identity of an already installed app, it treats the new manifest as a replacement for the existing app's manifest, even if the app is served from a different URL than the one installed previously.
Note:
While the id is processed like a URL, it does not point to a resource that can be accessed, so it is not required to be within the app's scope.
The id can also be used by services that collect lists of web apps to uniquely identify applications.
Usage notes
A few key points to remember while using the id member:
- As a recommended practice, use a leading
/to specify that theidis a root-relative URL path. - Since
idis resolved againststart_url's origin,idvalues such as../foo,foo,/foo, and./fooall resolve to the same identifier relative to the origin. For example, ifstart_urlishttps://example.com/app/, all theseidvalues will resolve tohttps://example.com/foo/. - Standard URL encoding and decoding rules apply when resolving the
idvalue. - Fragments in the
idare removed during processing. For example, ifidis set tofoo#bar, it will be resolved asfoo. Similarly, ifidis undefined and thestart_urlishttps://example.com/app/#home,idwill resolve tohttps://example.com/app/. - Query parameters in the
idare preserved and included in the final resolved identifier.
Understanding id resolution
Assume that the start_url for your app is https://example.com/my-app/home. The following table demonstrates how different id values in the manifest will be resolved:
id in manifest |
Resolved id |
Explanation |
|---|---|---|
| undefined | https://example.com/my-app/home |
Defaults to start_url |
"" |
https://example.com/my-app/home |
Empty string resolves to start_url |
/ |
https://example.com/ |
Root-relative URL |
foo?x=y |
https://example.com/foo?x=y |
Relative path resolved against start_url's origin with query parameters preserved |
foo#heading |
https://example.com/foo |
Relative path resolved against start_url's origin with fragment removed |
https://anothersite.com/foo |
https://example.com/my-app/home |
Cross-origin URL not allowed, falls back to start_url |
😀 |
https://example.com/%F0%9F%98%80 |
Non-ASCII character encoded in URL |
Examples
>Creating a distinct app version
Suppose you create a web app with the following manifest:
{
"name": "My Weather Application",
"id": "https://example.com/weatherapp/v1",
"start_url": "https://example.com/app"
}
If you later create another version of this app with significant changes and want it to be treated as a different app, you can add the manifest as:
{
"name": "My Weather Application",
"id": "https://example.com/weatherapp/v2",
"start_url": "https://example.com/app"
}
In this case, even though both manifest files are served from the same URL, browsers will treat the new manifest as a description of a distinct application because the id is different. As a result, users can have both versions installed simultaneously.
Updating an existing app
Consider a scenario where you deploy a web app with the following manifest:
{
"name": "My Weather Application",
"id": "https://example.com/weatherapp/",
"start_url": "https://example.com/old-app"
}
However, you later decide to move the app to a different path. You would then update the manifest as follows:
{
"name": "My Weather Application",
"id": "https://example.com/weatherapp/",
"start_url": "https://example.com/new-app"
}
Browsers will treat this new manifest as an update to the existing app because the id values match. In this case, users will receive an update to their existing app, rather than being prompted to install a new app.
Specifications
| Specification |
|---|
| Web Application Manifest> # id-member> |
Browser compatibility
Loading…