This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The register() method of the SharedStorageWorkletGlobalScope interface registers an operation defined inside the current worklet module.
register(name, operationCtor)
nameA string representing the name with which you want to register the operation. When the operation is invoked (say via WindowSharedStorage.run() or WindowSharedStorage.selectURL()), this name is used to identify the operation you want to run.
operationCtorA string representing the class name of the operation to be registered. This is the class constructor that is invoked when the operation is run.
None (undefined).
TypeErrorThrown if:
operationCtor is not a valid constructor.run() method.SharedStorageWorklet.addModule().// ab-testing-worklet.js
class SelectURLOperation {
async run(urls, data) {
// Read the user's experiment group from shared storage
const experimentGroup = await this.sharedStorage.get("ab-testing-group");
// Return the group number
return experimentGroup;
}
}
register("ab-testing", SelectURLOperation);
See the Shared Storage API landing page for a walkthrough of this example and for links to other examples.
Note: It is possible to define and register multiple operations in the same shared storage worklet module script with different names; see SharedStorageOperation for an example.
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
register |
126 | 126 | No | 112 | No | 126 | No | 83 | No | 28.0 | 126 | No |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/SharedStorageWorkletGlobalScope/register