Skip to content
AnswerWell geo Documentation

Research · 7 min read · Answerwell

Durable Object Name, Jurisdiction, and Location Hints

How Cloudflare Durable Objects expose ctx.id.name and ctx.id.jurisdiction, use getByName(), and choose jurisdiction versus locationHint for residency and latency.

This page summarises Cloudflare documentation on where a Durable Object runs, how to open it by name, and how to read its name and jurisdiction from inside the object—without passing those values through RPC arguments or durable storage.

getByName(): open a Durable Object by name from your Worker

Section titled “getByName(): open a Durable Object by name from your Worker”

getByName() creates a Durable Object stub (client) directly from a string name, so you no longer need idFromName() plus get() for the common case.

You can now create a client (a Durable Object stub) to a Durable Object with the new getByName method, removing the need to convert Durable Object names to IDs and then create a stub.

— Cloudflare, New getByName() API to access Durable Objects

const stub = env.MY_DURABLE_OBJECT.getByName("foo");
const rpcResponse = await stub.sayHello();

Cloudflare recommends meaningful deterministic names (for example a game or room ID) so every request for the same logical entity reaches the same instance. Use newUniqueId() when you need a random instance and will store the ID elsewhere (KV, D1, a cookie). Creating a stub does not wake the object; it activates when you invoke a method on the stub.

The stub exposes the name when created via getByName() or an ID from idFromName():

name is an optional property of a DurableObjectStub, which returns a name if it was provided upon stub creation either directly via DurableObjectNamespace::getByName or indirectly via a DurableObjectId created by DurableObjectNamespace::idFromName.

— Cloudflare, Durable Object Stub

Optional locationHint can be passed to get() or getByName(); only the first get() for a given object respects the hint (Durable Object Namespace).

ctx.id.name: read the Durable Object name inside the class

Section titled “ctx.id.name: read the Durable Object name inside the class”

Inside the Durable Object, this.ctx.id.name returns the same string passed to getByName() or idFromName(), which avoids threading the room or tenant name through every method and alarm handler.

When your Worker accesses a Durable Object via idFromName() or getByName(), the same name is now available on ctx.id.name inside the object — no need to pass it through method arguments or persist it in storage.

— Cloudflare, Access Durable Object name via ctx.id.name

export class ChatRoom extends DurableObject {
async getRoomName() {
return this.ctx.id.name;
}
}

That property is especially useful in alarms, where no client is present to pass the name:

When an alarm handler runs, ctx.id.name will hold the same name the object was originally accessed with.

— Cloudflare, Durable Object ID — name

ctx.id.name is undefined when:

  • the object was created with newUniqueId()
  • the caller used idFromString(), even if the ID was originally from a name
  • the name is longer than 1,024 bytes

The same rules apply on the DurableObjectId.name property outside the object (Durable Object ID).

Cloudflare still recommends an explicit init() for application metadata (who created the room, etc.) that is not part of the platform ID.

ctx.id.jurisdiction: read data jurisdiction inside the Durable Object

Section titled “ctx.id.jurisdiction: read data jurisdiction inside the Durable Object”

Jurisdiction restricts where the Durable Object runs and persists data (compliance boundaries such as eu, us, or fedramp). Workers anywhere can still call into a jurisdiction-scoped object; the constraint applies to the object’s compute and storage, not where the Worker runs (Restrict Durable Objects to a jurisdiction).

ctx.id.jurisdiction inside a Durable Object now reports the jurisdiction the object was created in — for example “eu” when accessed through env.MY_DURABLE_OBJECT.jurisdiction(“eu”) — so you can make region-aware decisions without passing the jurisdiction through method arguments or persisting it in storage.

— Cloudflare, Access Durable Object jurisdiction via ctx.id.jurisdiction

export class RegionalRoom extends DurableObject {
async fetch(request) {
const region = this.ctx.id.jurisdiction;
return new Response(`Hello from ${region ?? "the default region"}!`);
}
}

The value is also on DurableObjectId.jurisdiction, preserved across toString() / idFromString() round-trips and available in alarm handlers scheduled on or after 2026-03-15 (Durable Object ID — jurisdiction).

ctx.id.jurisdiction is undefined if the object was not created in a jurisdiction-restricted namespace. Alarms scheduled before 2026-03-15 may also lack jurisdiction until rescheduled from fetch() or RPC (Access Durable Object jurisdiction via ctx.id.jurisdiction).

jurisdiction(): restrict a namespace to eu, us, or fedramp

Section titled “jurisdiction(): restrict a namespace to eu, us, or fedramp”

Cloudflare recommends creating a jurisdiction subnamespace first, then obtaining IDs and stubs from it:

When specifying a jurisdiction, Cloudflare recommends you first create a namespace restricted to a jurisdiction, using const euSubnamespace = env.MY_DURABLE_OBJECT.jurisdiction(“eu”).

— Cloudflare, Restrict Durable Objects to a jurisdiction

const euSubnamespace = env.MY_DURABLE_OBJECT.jurisdiction("eu");
const stub = euSubnamespace.getByName("general");

The same logical name in different jurisdictions refers to different IDs:

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");

You get an error if the namespace jurisdiction and the ID’s jurisdiction disagree. newUniqueId({ jurisdiction: "eu" }) on the root namespace is possible but not recommended compared with jurisdiction("eu").

Durable Objects support a us jurisdiction for United States residency (New us jurisdiction for Durable Objects). For a full jurisdiction list, see Data location — Restrict Durable Objects to a jurisdiction.

locationHint versus jurisdiction: latency vs compliance

Section titled “locationHint versus jurisdiction: latency vs compliance”

These controls answer different questions. Jurisdiction is a hard residency boundary for run and storage. locationHint is a best-effort suggestion for where the object should be placed to reduce latency; it is not a guarantee.

Hints are a best effort and not a guarantee. Unlike with jurisdictions, Durable Objects will not necessarily be instantiated in the hinted location, but instead instantiated in a data center selected to minimize latency from the hinted location.

— Cloudflare, Data location — Provide a location hint

Mechanism Primary goal Typical values Mutable after create?
jurisdiction("eu") etc. Compliance / data residency eu, us, fedramp Encoded at ID / namespace scope; read via ctx.id.jurisdiction
locationHint on get() / getByName() Latency optimization wnam, enam, weur, apac, apac-ne, apac-se, oc, … Only first get() for that object counts

By default, a Durable Object is created near the first get() request. Cloudflare warns that pre-creating objects away from real user traffic can hurt latency. Objects do not currently relocate after creation (dynamic relocation is planned).

Asia-Pacific sub-hints apac-ne and apac-se

Section titled “Asia-Pacific sub-hints apac-ne and apac-se”

For APAC traffic concentrated in one sub-region:

Use apac-ne or apac-se when you want finer-grained placement within Asia-Pacific rather than the broader apac hint.

— Cloudflare, New Asia-Pacific location hints: apac-ne and apac-se

const stubNE = env.MY_DURABLE_OBJECT.get(id, { locationHint: "apac-ne" });
const stubSE = env.MY_DURABLE_OBJECT.get(id, { locationHint: "apac-se" });

If users span all of Asia-Pacific, apac remains the default recommendation unless you need finer placement (New Asia-Pacific location hints). Hints such as sam, afr, and me may map to nearby supported regions rather than spawning in that geography (Supported locations).

  • Storing the room name in KV when callers always use getByName("room-1")—ctx.id.name already carries it (Rules of Durable Objects).
  • Using idFromString() and expecting ctx.id.name—the name is not passed through that access path (Durable Object ID).
  • Treating locationHint as GDPR—use jurisdiction() for localization; hints only influence placement (Data location).
  • Mixing jurisdictions on namespace and ID, or assuming the same name is one global object across eu and default namespaces (Restrict Durable Objects to a jurisdiction).
  • Relying on old alarms for ctx.id.name / ctx.id.jurisdiction without rescheduling after 2026-03-15 (Durable Object ID).

Agents built on Durable Objects can pass jurisdiction or locationHint via getAgentByName() and routeAgentRequest() (Routing — Location hints and Jurisdiction). For broader platform jurisdiction patterns (D1, KV, Workflows), see each product’s data location pages; the create-time-only rule is the same pattern: jurisdiction is set at resource creation, not later.

  1. Update Wrangler (npm update wrangler) and run wrangler dev locally; confirm ctx.id.name and ctx.id.jurisdiction match how you call getByName() and jurisdiction() in a test handler.

  2. From a Worker, call getByName() with a fixed name and assert stub.name equals that string (Durable Object Stub).

  3. Create paired IDs with and without jurisdiction("eu") for the same name and verify they are not equal with DurableObjectId.equals() (Restrict Durable Objects to a jurisdiction).

  4. Log ctx.id from inside the object and, for production placement questions, cross-check regions using Where Durable Objects Live (linked from Cloudflare’s data-location reference).

  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact sentence you are asking about.