demo · v134

Interest Groups in Shared Storage Worklet

Shared Storage worklets can read Protected Audience interest groups via sharedStorage.interestGroups(). Click "run worklet" to attempt the call; the page reports what the API returned and any error.

Heads up Privacy Sandbox APIs need Chrome's Ad Topics / Site-suggested ads enabled and the origin enrolled. To exercise the full API in dev, set chrome://flags/#shared-storage-api and chrome://flags/#privacy-sandbox-ads-apis-override. The demo runs feature detection and attempts the call so you can see what's exposed.
probing...

Try it

The code

// inside the worklet:
class ReadIGs {
  async run() {
    const groups = await sharedStorage.interestGroups();
    console.log(groups);
  }
}
register("read-igs", ReadIGs);

// from the page:
await sharedStorage.worklet.addModule("worklet.js");
await sharedStorage.run("read-igs");

see also