durable
function durable<T extends DurableObjectBranded | undefined>(namespace: DurableObjectNamespace<T>, name: string, opts?: DurableAddressingOpts): DurableStub<T>Resolves a named Durable Object stub from a typed namespace.
- No placement opts: calls
namespace.getByName(name). locationHintonly: callsnamespace.getByName(name, { locationHint }).jurisdiction(with or withoutlocationHint): callsnamespace.jurisdiction(jurisdiction).getByName(name, remainingOpts).
The returned stub carries the namespace type parameter T, so RPC methods on the
DO class are available without casting.
namespace DurableObjectNamespace<T> · The typed DurableObjectNamespace<T> from scope.bindings.env.MY_BINDING.
name string · The stable string name for this DO instance.
opts? DurableAddressingOpts · Optional placement and jurisdiction hints.
returns DurableStub<T>
Learn: Overview