skip to content

In Cloudflare Durable Objects, how do a locationHint and a jurisdiction differ in controlling where an object runs and stores its data?

level: middleimportance: should knowfreq 32%

answer

  1. default: near the first caller
  2. hint is best effort
  3. only the first get() counts
  4. subnamespace for compliance
  5. same name, different ID

basics

~20 s

A locationHint passed to get() or getByName() is a best-effort latency hint honoured only when the object is first created; a jurisdiction such as jurisdiction("eu") is a guarantee that the object runs and stores data only in that region.

solid answer

~40 s

By default an object is created near the Worker that first reaches it and does not currently move afterwards. A **`locationHint`** (`env.DOCUMENT.get(id, { locationHint: "weur" })`, or the same option on `getByName()`) steers that first placement: it is best effort, applies only to the call that creates the object, and is ignored for one that already exists. A **jurisdiction** is a compliance boundary: `env.DOCUMENT.jurisdiction("eu")` returns a subnamespace whose objects run and persist data only inside the EU (`eu`, `us` and `fedramp` are documented). The same name gives a different ID inside a jurisdiction, Workers anywhere can still call those objects, and the ID itself may be logged outside the region. Inside the object, `ctx.id.jurisdiction` reports it.

go deeper

for a junior

Recall that an object is created near its first caller, and that jurisdiction("eu") keeps an object's compute and storage inside the EU.

for a middle

Explain that a hint is best effort and applies only on first creation, while a jurisdiction is part of the ID and changes it for the same name.

for a senior

Show the operational traps: pre-creation from one region, names leaking into logs, migrating existing objects into a jurisdiction, and local dev throwing.

for a principal

Decide per tenant whether residency is a contractual guarantee needing a jurisdiction from day one, since retrofitting means copying every object's data.

## Where an object lives by default A **Durable Object** runs in one Cloudflare data center at a time, and its storage sits beside it. When an object is first reached, the platform creates it in a data center **close to where that first request came from** (not necessarily the same one, but nearby). Objects do not currently relocate after creation; dynamic relocation is described as planned. Two consequences matter for a collaborative document editor: - The first editor of a document decides where its object lives. If a London user creates a document that a team in Tokyo then edits all day, Tokyo pays the round trip. - **Pre-creating objects** from somewhere unrepresentative, such as a scheduled job or a migration script running in one region, places them all near that job. Cloudflare explicitly warns this can hurt latency. ## `locationHint`: a best-effort latency hint You can pass a hint as the second argument to `get()` or `getByName()`: ```javascript const stub = env.DOCUMENT.getByName(docId, { locationHint: "apac" }); ``` - It is honoured **only on the first call that creates the object**; for an existing object it does nothing. - It is **best effort**: the object is placed in a data center chosen to minimise latency from the hinted area, not necessarily inside it. - Some hinted areas (`sam`, `afr`, `me`) do not currently host objects, so they spawn in a nearby supported location instead. - Valid values: `wnam`, `enam`, `sam`, `weur`, `eeur`, `apac`, `apac-ne`, `apac-se`, `oc`, `afr`, `me`. Cloudflare's advice is to omit the hint unless you know the first request is unrepresentative, for example when a workspace's region is known from the account record. ## Jurisdiction: a data-location guarantee A **jurisdiction** restricts where an object **runs and persists data**, for regulations such as the GDPR or FedRAMP. You get one by deriving a subnamespace: ```javascript const eu = env.DOCUMENT.jurisdiction("eu"); const stub = eu.getByName(docId); ``` Rules to know: - **Documented jurisdictions** are `eu` (the European Union), `us` (the United States, added in June 2026) and `fedramp` (FedRAMP-Moderate data centers). - **The same name yields a different ID** in a jurisdiction: `env.DOCUMENT.idFromName("doc-42")` and `env.DOCUMENT.jurisdiction("eu").idFromName("doc-42")` are different objects with separate storage. Switching an existing document to a jurisdiction therefore means a new object and a data copy, not a flag flip. - **Access is not restricted.** Workers anywhere in the world can still call an EU object; only its execution and storage stay in the region. Controlling where requests are *answered* is a separate product. - **IDs leak by design.** A `DurableObjectId` may be logged outside the jurisdiction for billing and debugging, so never put personal data in an object name. - **The jurisdiction travels with the ID.** `toString()` encodes it, so `idFromString()` on the plain namespace still reaches the restricted object, and `ctx.id.jurisdiction` reports it inside the object. - Calling `newUniqueId({ jurisdiction: "eu" })` also works, but Cloudflare recommends the subnamespace form. ## Side by side | | `locationHint` | `jurisdiction()` | |---|---|---| | Purpose | latency | compliance | | Strength | best effort | guarantee | | When applied | first creation only | always, part of the ID | | Changes the ID? | no | yes, same name gives a new ID | | Restricts storage? | no | yes | | Restricts who can call? | no | no | Neither one adds capacity: a hot object stays one thread wherever it lives. ## Choosing in practice - **No residency requirement, users near the creator**: use neither; default placement is usually right. - **Known home region, unrepresentative first request** (an admin in one country sets up a workspace used elsewhere): pass a `locationHint` on the creating call. - **Contractual or regulatory residency**: create the tenant's objects through `jurisdiction()` from the first day, and keep the tenant-to-jurisdiction mapping in configuration or the tenant record so every Worker derives the same subnamespace. - **Mixed tenants**: route by tenant, `env.DOCUMENT.jurisdiction("eu")` for EU tenants and the plain namespace for others; never let a request choose its own jurisdiction from untrusted input. ## Local development caveat The local runtime behind `wrangler dev` does not implement jurisdictions: calling `jurisdiction("eu")` there throws `Jurisdiction restrictions are not implemented in workerd.` Keep the jurisdiction choice behind configuration you can switch for local runs, and verify residency against the real platform.

  • An EU customer's documents already live in objects created with plain idFromName(). How do you move them into the EU jurisdiction?
    There is no in-place switch: the same name inside jurisdiction("eu") is a different ID with empty storage. Create the new objects through the EU subnamespace, copy each document's state across, route new traffic there, and then retire the old objects. Plan it as a data migration.
  • Why does jurisdiction("eu") fail under wrangler dev?
    The local runtime does not implement jurisdiction restrictions and throws an error when one is requested. Read the jurisdiction from configuration so local runs can use the plain namespace, and test residency on the deployed platform, where the restriction is enforced.
  • Should a document's object name include the customer's email address for easy debugging?
    No. Object IDs can be logged outside the jurisdiction for billing and debugging, and the name is what the ID is derived from. Use an opaque document or tenant identifier and keep personal data in the object's storage, which stays in the region.

  • A locationHint guarantees the object stays inside the hinted region
  • A locationHint on any later get() moves an existing object
  • A jurisdiction blocks Workers outside the region from calling the object
  • The same name reaches the same object with or without a jurisdiction
  • Pre-creating every object from a cron job gives the best latency

Assumes Cloudflare's platform as of 2026-10-10: the us jurisdiction was added in June 2026, the apac-ne and apac-se hints in June 2026, and ctx.id.jurisdiction is reported inside the object since March 2026.