Cloudflare Docs
Durable Objects
Edit this page on GitHub
Set theme to dark (⇧+D)

Data location

You can restrict a Durable Object to a jurisdiction, or provide a location hint.

​​ Restrict Durable Objects to a jurisdiction

Durable Objects can be created so that they only run and store data within a specific jurisdiction to comply with local regulations such as the GDPR or FedRAMP.

To use a jurisdiction, first create a jurisidictional subnamespace in your Worker’s code:

let subnamespace = OBJECT_NAMESPACE.jurisdiction('eu');

A jurisdictional subnamespace works like a normal Durable Object namespace (OBJECT_NAMESPACE above), except that IDs created within them permanently encode the jurisdiction that was used to create the subnamespace. Additionally, the idFromString() and get() methods will throw an exception if the IDs passed into them are not within the subnamespace’s jurisdiction. Once you have a subnamespace, you can use all of the namespace methods documented above.

To create a new Durable Object ID that will only run and persist data within the jurisdiction:

let id = subnamespace.newUniqueId();

To derive a unique Object ID from the given name string that will only run and persist data within the jurisdiction:

let id = subnamespace.idFromName(name);

To parse a previously-created ID from a string:

let id = subnamespace.idFromString(id);

To obtain an Object:

let durableObjectStub = subnamespace.get(id)

While you cannot use an ID from a different jurisdiction in a subnamespace’s idFromString() or get() methods, you can use any valid ID in the top-level namespace’s methods. Object IDs created with a jurisdiction will still only run and persist data within the jurisdiction.

let id = subnamespace.idFromName(name);
// This is valid.
OBJECT_NAMESPACE.idFromString(id.toString())
// And so is this.
OBJECT_NAMESPACE.get(id)

Your 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.

The currently supported jurisdictions are eu (the European Union) and fedramp (FedRAMP).

​​ 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' });

The following locations are supported:

Location Hint 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.