You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `DurableObjectId` interface refers to a new or existing Durable Object instance. This interface is most frequently used by [`DurableObjectNamespace::get`](./namespace.mdx) to obtain a stub for submitting requests to the Durable Object class.
12
+
The `DurableObjectId` interface refers to a new or existing Durable Object instance. This interface is most frequently used by [`DurableObjectNamespace::get`](/durable-objects/api/namespace/#get) to obtain a stub for submitting requests to the Durable Object class.
13
13
14
-
Note that creating an ID for a Durable Object instance does not invoke the constructor of the Durable Object. This is done lazily when calling [`DurableObjectNamespace::get`](../namespace/#get) to create a [`DurableObjectStub`](../stub) from a `DurableObjectId`. This ensures that objects are not constructed unless their methods can be directly invoked.
14
+
Note that creating an ID for a Durable Object instance does not invoke the constructor of the Durable Object. This is done lazily when calling [`DurableObjectNamespace::get`](/durable-objects/api/namespace/#get) to create a [`DurableObjectStub`](/durable-objects/api/stub) from a `DurableObjectId`. This ensures that objects are not constructed unless their methods can be directly invoked.
15
15
16
16
:::note[`DurableObjectId`]
17
17
@@ -70,7 +70,7 @@ A boolean. True if equal and false otherwise.
70
70
71
71
#### Description
72
72
73
-
`name` is an optional property of a `DurableObjectId`, which returns the name that was used to create the `DurableObjectId` via [`DurableObjectNamespace::idFromName`](../namespace/#idfromname). This value is undefined if the `DurableObjectId` was constructed using [`DurableObjectNamespace::newUniqueId`](../namespace/#newuniqueid).
73
+
`name` is an optional property of a `DurableObjectId`, which returns the name that was used to create the `DurableObjectId` via [`DurableObjectNamespace::idFromName`](/durable-objects/api/namespace/#idfromname). This value is undefined if the `DurableObjectId` was constructed using [`DurableObjectNamespace::newUniqueId`](/durable-objects/api/namespace/#newuniqueid).
The `DurableObjectNamespace` interface is used to obtain a reference to a new or existing Durable Object instance. The interface is accessible from the fetch handler on a Cloudflare Worker via the `env` parameter, which is the standard interface when referencing bindings declared in `wrangler.toml`.
13
13
14
-
This interface defines several [methods](../namespace/#methods) that can be used to create an ID for a Durable Object instance. Note that creating an ID for a Durable Object instance does not invoke the constructor of the Durable Object. This is done lazily when calling [`DurableObjectNamespace::get`](../namespace/#get) to create a [`DurableObjectStub`](../stub) from a `DurableObjectId`. This ensures that objects are not constructed unless their methods can be directly invoked.
14
+
This interface defines several [methods](/durable-objects/api/namespace/#methods) that can be used to create an ID for a Durable Object instance. Note that creating an ID for a Durable Object instance does not invoke the constructor of the Durable Object. This is done lazily when calling [`DurableObjectNamespace::get`](/durable-objects/api/namespace/#get) to create a [`DurableObjectStub`](/durable-objects/api/stub) from a `DurableObjectId`. This ensures that objects are not constructed unless their methods can be directly invoked.
`idFromName` creates a [`DurableObjectId`](../id) which refers to an individual instance of the Durable Object class from a particular name.
74
+
`idFromName` creates a [`DurableObjectId`](/durable-objects/api/id) which refers to an individual instance of the Durable Object class from a particular name.
IDs created by `newUniqueId` will result in lower latencies when getting a [`DurableObjectStub`](../stub) relative to [`idFromName`](../namespace/#idFromName).
102
+
IDs created by `newUniqueId` will result in lower latencies when getting a [`DurableObjectStub`](/durable-objects/api/stub) relative to [`idFromName`](/durable-objects/api/namespace/#idfromname).
103
103
104
104
:::
105
105
106
106
#### Parameters
107
107
108
-
An optional object with the key `jurisdiction` and value of a [jurisdiction](../../reference/data-location/#restrict-durable-objects-to-a-jurisdiction) string.
108
+
An optional object with the key `jurisdiction` and value of a [jurisdiction](durable-objects/reference/data-location/#restrict-durable-objects-to-a-jurisdiction) string.
109
109
110
110
#### Return value
111
111
112
-
A [`DurableObjectId`](../id) referring to an instance of the Durable Object class.
112
+
A [`DurableObjectId`](/durable-objects/api/id) referring to an instance of the Durable Object class.
113
113
114
114
### `idFromString`
115
115
116
116
#### Description
117
117
118
-
`idFromString` creates a [`DurableObjectId`](../id) from a previously generated ID that has been converted to a string. This method ensures the ID is valid, for example, it checks that the ID consists of 64 hex digits.
118
+
`idFromString` creates a [`DurableObjectId`](/durable-objects/api/id) from a previously generated ID that has been converted to a string. This method ensures the ID is valid, for example, it checks that the ID consists of 64 hex digits.
119
119
120
120
```js
121
121
// Create a new unique ID
@@ -128,17 +128,17 @@ const id = env.MY_DURABLE_OBJECT.idFromString(session_id);
128
128
129
129
#### Parameters
130
130
131
-
The string corresponding to a [`DurableObjectId`](../id) previously generated either by `newUniqueId` or `idFromName`.
131
+
The string corresponding to a [`DurableObjectId`](/durable-objects/api/id) previously generated either by `newUniqueId` or `idFromName`.
132
132
133
133
#### Return value
134
134
135
-
A [`DurableObjectId`](../id) referring to an instance of a Durable Object class.
135
+
A [`DurableObjectId`](/durable-objects/api/id) referring to an instance of a Durable Object class.
136
136
137
137
### `get`
138
138
139
139
#### Description
140
140
141
-
`get` obtains a [`DurableObjectStub`](../stub) from a [`DurableObjectId`](../id) which can be used to invoke methods on a Durable Object instance.
141
+
`get` obtains a [`DurableObjectStub`](/durable-objects/api/stub) from a [`DurableObjectId`](/durable-objects/api/id) which can be used to invoke methods on a Durable Object instance.
A required [`DurableObjectId`](../id) and an optional object with the key `locationHint` and value of a [locationHint](../../reference/data-location/#provide-a-location-hint) string.
150
+
A required [`DurableObjectId`](/durable-objects/api/id) and an optional object with the key `locationHint` and value of a [locationHint](durable-objects/reference/data-location/#provide-a-location-hint) string.
151
151
152
152
#### Return value
153
153
154
-
A [`DurableObjectStub`](../stub) referring to an instance of a Durable Object class.
154
+
A [`DurableObjectStub`](/durable-objects/api/stub) referring to an instance of a Durable Object class.
155
155
156
156
### `jurisdiction`
157
157
158
158
#### Description
159
159
160
-
`jurisdiction` creates a subnamespace from a namespace where all Durable Object instance IDs and references created from that subnamespace will be restricted to the specified [jurisdiction](../../reference/data-location/#restrict-durable-objects-to-a-jurisdiction).
160
+
`jurisdiction` creates a subnamespace from a namespace where all Durable Object instance IDs and references created from that subnamespace will be restricted to the specified [jurisdiction](durable-objects/reference/data-location/#restrict-durable-objects-to-a-jurisdiction).
Copy file name to clipboardExpand all lines: src/content/docs/durable-objects/api/stub.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -89,7 +89,7 @@ export default {
89
89
90
90
#### Description
91
91
92
-
`id` is a property of the `DurableObjectStub` corresponding to the [`DurableObjectId`](../id) used to create the stub.
92
+
`id` is a property of the `DurableObjectStub` corresponding to the [`DurableObjectId`](/durable-objects/api/id) used to create the stub.
93
93
94
94
```js
95
95
constid=env.MY_DURABLE_OBJECT.newUniqueId();
@@ -101,7 +101,7 @@ console.assert(id.equals(stub.id), "This should always be true");
101
101
102
102
#### Description
103
103
104
-
`name` is an optional property of a `DurableObjectStub`, which returns the name that was used to create the [`DurableObjectId`](../id) via [`DurableObjectNamespace::idFromName`](../namespace/#idfromname) which was then used to create the `DurableObjectStub`. This value is undefined if the [`DurableObjectId`](../id) used to create the `DurableObjectStub` was constructed using [`DurableObjectNamespace::newUniqueId`](../namespace/#newuniqueid).
104
+
`name` is an optional property of a `DurableObjectStub`, which returns the name that was used to create the [`DurableObjectId`](/durable-objects/api/id) via [`DurableObjectNamespace::idFromName`](/durable-objects/api/namespace/#idfromname) which was then used to create the `DurableObjectStub`. This value is undefined if the [`DurableObjectId`](/durable-objects/api/id) used to create the `DurableObjectStub` was constructed using [`DurableObjectNamespace::newUniqueId`](/durable-objects/api/namespace/#newuniqueid).
0 commit comments