Domain-specific storage

Is there a way to identify the domain of the page/tab that a storage entry was created on? I want to store a couple of small preferences on a per-site basis; on one hand cookies would be perfect but I don’t necessarily want the prefs to be sent to the remote server on every request (or at all!)

You can use a storage with domain as a key (or value).

Domain as a value:{ myData: { domain: window.location.hostname, value: "whatever" } })

Domain as a key:

const domain = window.location.hostname;{ [`myData_${domain}`]: "whatever" })

Domain as a key inside a value:

const domain = window.location.hostname;
const {myData} = await'myData');
myData[domain] = "whatever";