Skip to content

Data location

Restrict Durable Objects to a jurisdiction

Jurisdictions are used to create Durable Objects that only run and store data within a region to comply with local regulations such as the GDPR or FedRAMP.

Workers may still access Durable Objects constrained to a jurisdiction from anywhere in the world. The jurisdiction constraint only controls where the Durable Object itself runs and persists data. Consider using Regional Services to control the regions from which Cloudflare responds to requests.

Durable Objects can be restricted to a specific jurisdiction either by creating a DurableObjectNamespace restricted to a jurisdiction, or by creating an individual DurableObjectId restricted to a jurisdiction:

const euSubnamespace = env.MY_DURABLE_OBJECT.jurisdiction("eu");
const euId = euSubnamespace.newUniqueId();
// or
const euId = env.MY_DURABLE_OBJECT.newUniqueId({ jurisdiction: "eu" });

Methods on a DurableObjectNamespace that take a DurableObjectId as a parameter will throw an exception if the parameter is associated with a different jurisdiction. To achieve this, a DurableObjectId encodes its jurisdiction. As a consequence, it is possible to have the same name represent different IDs in different jurisdictions.

const euId1 = env.MY_DURABLE_OBJECT.idFromName("my-name");
const euId2 = env.MY_DURABLE_OBJECT.jurisdiction("eu").idFromName("my-name");
console.assert(!euId1.equal(euId2), "This should always be true");

Methods on a DurableObjectNamespace that take a DurableObjectId as a parameter will throw an exception if the parameter is associated with a different jurisdiction. However, these methods will not throw an exception if the DurableObjectNamespace is not associated with a jurisdiction. The common case is that any valid DurableObjectId can be used in the top-level namespace's methods.

const euSubnamespace = env.MY_DURABLE_OBJECT.jurisdiction("eu");
const euId = euSubnamespace.idFromName(name);
const stub = env.MY_DURABLE_OBJECT.get(euId);

Supported locations

ParameterLocation
euThe European Union
fedrampFedRAMP-compliant data centers

Provide a location hint

Durable Objects, as with any stateful API, will often add response latency as requests must be forwarded to the data center where the Durable Object, or state, is located.

Durable Objects do not currently change locations after they are created1. By default, a Durable Object is instantiated in a data center close to where the initial get() request is made. This may not be in the same data center that the get() request is made from, but in most cases, it will be in close proximity.

Location hints are the mechanism provided to specify the location that a Durable Object should be located regardless of where the initial get() request comes from.

To manually create Durable Objects in another location, provide an optional locationHint parameter to get(). Only the first call to get() for a particular Object will respect the hint.

let durableObjectStub = OBJECT_NAMESPACE.get(id, { locationHint: "enam" });

Supported locations

ParameterLocation
wnamWestern North America
enamEastern North America
samSouth America
weurWestern Europe
eeurEastern Europe
apacAsia-Pacific
ocOceania
afrAfrica
meMiddle East

1 Dynamic relocation of existing Durable Objects is planned for the future.