contextualIdentities

Work with contextual identities: list, create, remove, and update contextual identities.

"Contextual identities", also known as "containers", are a browser feature that lets users assume multiple identities when browsing the web, and maintain some separation between these identities. For example, a user might consider their "work identity" separate from their "personal identity", and not want to share cookies between these two contexts.

With the contextual identities feature, each contextual identity has a name, a color, and an icon. New tabs can be assigned to an identity, and the name, icon, and color appears in the address bar. Internally, each identity gets a cookie store that is not shared with other tabs. This cookie store is identified by the cookieStoreId in this and other APIs.

A context menu with "open in new container tab" submenu highlighted. The submenu shows personal, work, banking, and shopping contextual identities.

Contextual identities are an experimental feature in Firefox and are only enabled by default in Firefox Nightly. To enable them in other versions of Firefox, set the privacy.userContext.enabled preference to true. Note that although contextual identities are available in Firefox for Android, there's no UI to work with them in this version of the browser.

Before Firefox 57, the contextualIdentities API is only available if the contextual identities feature is itself enabled. If an extension tried to use the contextualIdentities API without the feature being enabled, then method calls would resolve their promises with false.

From Firefox 57 onwards, if an extension that uses the contextualIdentities API is installed, then the contextual identities feature will be enabled automatically. Note though that it's still possible for the user to disable the feature using the "privacy.userContext.enabled" preference. If this happens, then contextualIdentities method calls will reject their promises with an error message.

See Work with contextual identities for more information.

Contextual identities are not supported in any other browsers.

To use this API you need to include the "contextualIdentities" and "cookies" permissions in your manifest.json file.

Types

contextualIdentities.ContextualIdentity

Contains information about a contextual identity.

Functions

contextualIdentities.create()

Creates a new contextual identity.

contextualIdentities.get()

Retrieves a contextual identity, given its cookie store ID.

contextualIdentities.move()

Moves one or more contextual identities within the list of contextual identities.

contextualIdentities.query()

Retrieves all contextual identities, or all contextual identities with a particular name.

contextualIdentities.update()

Updates properties of an existing contextual identity.

contextualIdentities.remove()

Deletes a contextual identity.

Events

contextualIdentities.onCreated

Fired when a contextual identity is created.

contextualIdentities.onRemoved

Fired when a contextual identity is removed.

contextualIdentities.onUpdated

Fired when one or more properties of a contextual identity is updated.

Example extensions

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
contextualIdentities
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 53 (Release date: 2017-04-19)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote
footnote Until Firefox for Android 137 contextualIdentities is defined but not functional. From Firefox for Android 138 contextualIdentities is inaccessible.
footnote See bug 1638878
Safari on iOS – No support
Safari on iOS
footnote No support
ContextualIdentity
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 53 (Release date: 2017-04-19)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote
footnote Until Firefox for Android 137 contextualIdentities is defined but not functional. From Firefox for Android 138 contextualIdentities is inaccessible.
footnote See bug 1638878
Safari on iOS – No support
Safari on iOS
footnote No support
ContextualIdentity.color
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 53 (Release date: 2017-04-19)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote
footnote Until Firefox for Android 137 contextualIdentities is defined but not functional. From Firefox for Android 138 contextualIdentities is inaccessible.
footnote See bug 1638878
Safari on iOS – No support
Safari on iOS
footnote No support
ContextualIdentity.colorCode
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 57 (Release date: 2017-11-14)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote
footnote Until Firefox for Android 137 contextualIdentities is defined but not functional. From Firefox for Android 138 contextualIdentities is inaccessible.
footnote See bug 1638878
Safari on iOS – No support
Safari on iOS
footnote No support
ContextualIdentity.cookieStoreId
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 53 (Release date: 2017-04-19)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote
footnote Until Firefox for Android 137 contextualIdentities is defined but not functional. From Firefox for Android 138 contextualIdentities is inaccessible.
footnote See bug 1638878
Safari on iOS – No support
Safari on iOS
footnote No support
ContextualIdentity.icon
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 53 (Release date: 2017-04-19)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote
footnote Until Firefox for Android 137 contextualIdentities is defined but not functional. From Firefox for Android 138 contextualIdentities is inaccessible.
footnote See bug 1638878
Safari on iOS – No support
Safari on iOS
footnote No support
ContextualIdentity.iconUrl
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 57 (Release date: 2017-11-14)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote
footnote Until Firefox for Android 137 contextualIdentities is defined but not functional. From Firefox for Android 138 contextualIdentities is inaccessible.
footnote See bug 1638878
Safari on iOS – No support
Safari on iOS
footnote No support
ContextualIdentity.name
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 53 (Release date: 2017-04-19)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote
footnote Until Firefox for Android 137 contextualIdentities is defined but not functional. From Firefox for Android 138 contextualIdentities is inaccessible.
footnote See bug 1638878
Safari on iOS – No support
Safari on iOS
footnote No support
create
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 53 (Release date: 2017-04-19)
footnote
footnote Before version 57, this method resolves its promise with false if the contextual identities feature is disabled.
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote
footnote Until Firefox for Android 137 contextualIdentities is defined but not functional. From Firefox for Android 138 contextualIdentities is inaccessible.
footnote See bug 1638878
Safari on iOS – No support
Safari on iOS
footnote No support
get
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 53 (Release date: 2017-04-19)
footnote
footnote Before version 57, this method resolves its promise with false if the contextual identities feature is disabled.
footnote Before version 57, this method resolves its promise with null if the given identity is not found.
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote
footnote Until Firefox for Android 137 contextualIdentities is defined but not functional. From Firefox for Android 138 contextualIdentities is inaccessible.
footnote See bug 1638878
Safari on iOS – No support
Safari on iOS
footnote No support
move
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 123 (Release date: 2024-02-20)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote
footnote Until Firefox for Android 137 contextualIdentities is defined but not functional. From Firefox for Android 138 contextualIdentities is inaccessible.
footnote See bug 1638878
Safari on iOS – No support
Safari on iOS
footnote No support
onCreated
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 57 (Release date: 2017-11-14)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote
footnote Until Firefox for Android 137 contextualIdentities is defined but not functional. From Firefox for Android 138 contextualIdentities is inaccessible.
footnote See bug 1638878
Safari on iOS – No support
Safari on iOS
footnote No support
onRemoved
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 57 (Release date: 2017-11-14)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote
footnote Until Firefox for Android 137 contextualIdentities is defined but not functional. From Firefox for Android 138 contextualIdentities is inaccessible.
footnote See bug 1638878
Safari on iOS – No support
Safari on iOS
footnote No support
onUpdated
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 57 (Release date: 2017-11-14)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote
footnote Until Firefox for Android 137 contextualIdentities is defined but not functional. From Firefox for Android 138 contextualIdentities is inaccessible.
footnote See bug 1638878
Safari on iOS – No support
Safari on iOS
footnote No support
query
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 53 (Release date: 2017-04-19)
footnote
footnote Before version 57, this method resolves its promise with false if the contextual identities feature is disabled.
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote
footnote Until Firefox for Android 137 contextualIdentities is defined but not functional. From Firefox for Android 138 contextualIdentities is inaccessible.
footnote See bug 1638878
Safari on iOS – No support
Safari on iOS
footnote No support
remove
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 53 (Release date: 2017-04-19)
footnote
footnote Before version 57, this method resolves its promise with false if the contextual identities feature is disabled.
footnote Before version 57, this method resolves its promise with null if the given identity is not found.
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote
footnote Until Firefox for Android 137 contextualIdentities is defined but not functional. From Firefox for Android 138 contextualIdentities is inaccessible.
footnote See bug 1638878
Safari on iOS – No support
Safari on iOS
footnote No support
update
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 53 (Release date: 2017-04-19)
footnote
footnote Before version 57, this method resolves its promise with false if the contextual identities feature is disabled.
footnote Before version 57, this method resolves its promise with null if the given identity is not found.
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote
footnote Until Firefox for Android 137 contextualIdentities is defined but not functional. From Firefox for Android 138 contextualIdentities is inaccessible.
footnote See bug 1638878
Safari on iOS – No support
Safari on iOS
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.