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
Durable Objects is generally available. However, there are some known issues.
14
9
@@ -41,74 +36,3 @@ The Workers editor in the [Cloudflare dashboard](https://dash.cloudflare.com/) a
41
36
Currently, when developing locally (using `npx wrangler dev`), Durable Object [alarm methods](/durable-objects/api/alarms) may fail after a hot reload (if you edit the code while the code is running locally).
42
37
43
38
To avoid this issue, when using Durable Object alarms, close and restart your `wrangler dev` command after editing your code.
44
-
45
-
## Local development with web frameworks
46
-
47
-
When developing a Pages or Workers Assets application, you may have to define your Durable Object in a separate Worker in order to develop locally.
48
-
This only applies to frameworks that use a development server that runs in Node.js. We are working to improve this experience - for example, frameworks that use the Cloudflare Vite plugin do not have this issue.
49
-
50
-
For now, you can set up your project like this to enable local development. In this example, we assume you have a pre-existing Worker that you want to add a DO binding to.
51
-
52
-
<Steps>
53
-
1. Create a second Worker with your Durable Object code.
54
-
55
-
```ts title="src/index.ts"
56
-
exportclassMyDurableObjectextendsDurableObject {
57
-
// Your DO code goes here
58
-
}
59
-
60
-
exportdefault {
61
-
fetch() {
62
-
// Doesn't have to do anything, but a DO cannot be the default export
63
-
returnnewResponse("Hello, world!");
64
-
},
65
-
};
66
-
```
67
-
68
-
2. Create a **new** Wrangler config file for this Worker.
69
-
70
-
<WranglerConfig>
71
-
```json
72
-
{
73
-
"name": "external-do-worker",
74
-
"main": "src/index.ts",
75
-
"compatibility_date": "XXXX-XX-XX"
76
-
}
77
-
```
78
-
</WranglerConfig>
79
-
80
-
3. Update your **original** Durable Object bindings in your pre-existing Wrangler config file to include the `script_name` field. This should be the same as the `name` field in the new Worker's config.
81
-
82
-
<WranglerConfig>
83
-
84
-
```json
85
-
{
86
-
...
87
-
"durable_objects": {
88
-
"bindings": [
89
-
{
90
-
"name": "BINDING",
91
-
"class_name": "MyDurableObject",
92
-
"script_name": "external-do-worker",
93
-
},
94
-
],
95
-
},
96
-
...
97
-
},
98
-
```
99
-
100
-
</WranglerConfig>
101
-
102
-
4. Develop locally
103
-
104
-
If you are not using RPC with your Durable Object, you can run a separate Wrangler dev session alongside your framework development server.
105
-
106
-
Otherwise, you can build your application and run both Workers in the same Wrangler dev session.
107
-
108
-
If you are using Pages:
109
-
<PackageManagerstype="exec"pkg="wrangler"args="pages dev -c path/to/pages/wrangler.jsonc -c path/to/external-do-worker/wrangler.jsonc" />
Wrangler offers APIs to programmatically interact with your Cloudflare Workers.
14
22
@@ -360,27 +368,6 @@ The bindings supported by `getPlatformProxy` are:
360
368
361
369
-[KV namespace bindings](/kv/api/)
362
370
363
-
-[Durable Object bindings](/durable-objects/api/)
364
-
365
-
- To use a Durable Object binding with `getPlatformProxy`, always [specify a `script_name`](/workers/wrangler/configuration/#durable-objects) and have the target Worker run in a separate terminal via [`wrangler dev`](/workers/wrangler/commands/#dev).
366
-
367
-
For example, you might have the following file read by `getPlatformProxy`.
368
-
369
-
<WranglerConfig>
370
-
371
-
```toml
372
-
[[durable_objects.bindings]]
373
-
name = "MyDurableObject"
374
-
class_name = "MyDurableObject"
375
-
script_name = "my-worker"
376
-
```
377
-
378
-
</WranglerConfig>
379
-
380
-
In order for this binding to be successfully proxied by `getPlatformProxy`, a worker named `my-worker`
381
-
with a Durable Object declaration using the same `class_name` of `"MyDurableObject"` must be run
0 commit comments