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
Copy file name to clipboardExpand all lines: src/content/docs/browser-rendering/workers-binding-api/browser-rendering-with-DO.mdx
+6-14Lines changed: 6 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,23 +33,15 @@ Create a new Worker project named `browser-worker` by running:
33
33
args={"browser-worker"}
34
34
/>
35
35
36
-
## 2. Enable Durable Objects in the dashboard
37
-
38
-
To enable Durable Objects, you will need to purchase the Workers Paid plan:
39
-
40
-
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com/), and select your account.
41
-
2. Go to **Workers & Pages** > **Plans**.
42
-
3. Select **Purchase Workers Paid** and complete the payment process to enable Durable Objects.
43
-
44
-
## 3. Install Puppeteer
36
+
## 2. Install Puppeteer
45
37
46
38
In your `browser-worker` directory, install Cloudflare’s [fork of Puppeteer](/browser-rendering/platform/puppeteer/):
47
39
48
40
```sh
49
41
npm install @cloudflare/puppeteer --save-dev
50
42
```
51
43
52
-
## 4. Create a R2 bucket
44
+
## 3. Create a R2 bucket
53
45
54
46
Create two R2 buckets, one for production, and one for development.
55
47
@@ -68,7 +60,7 @@ wrangler r2 bucket list
68
60
69
61
After running the `list` command, you will see all bucket names, including the ones you have just created.
70
62
71
-
## 5. Configure your Wrangler configuration file
63
+
## 4. Configure your Wrangler configuration file
72
64
73
65
Configure your `browser-worker` project's [Wrangler configuration file](/workers/wrangler/configuration/) by adding a browser [binding](/workers/runtime-apis/bindings/) and a [Node.js compatibility flag](/workers/configuration/compatibility-flags/#nodejs-compatibility-flag). Browser bindings allow for communication between a Worker and a headless browser which allows you to do actions such as taking a screenshot, generating a PDF and more.
74
66
@@ -106,7 +98,7 @@ new_classes = ["Browser"] # Array of new classes
106
98
107
99
</WranglerConfig>
108
100
109
-
## 6. Code
101
+
## 5. Code
110
102
111
103
The code below uses Durable Object to instantiate a browser using Puppeteer. It then opens a series of web pages with different resolutions, takes a screenshot of each, and uploads it to R2.
112
104
@@ -219,11 +211,11 @@ export class Browser {
219
211
}
220
212
```
221
213
222
-
## 7. Test
214
+
## 6. Test
223
215
224
216
Run [`npx wrangler dev --remote`](/workers/wrangler/commands/#dev) to test your Worker remotely before deploying to Cloudflare's global network. Local mode support does not exist for Browser Rendering so `--remote` is required.
225
217
226
-
## 8. Deploy
218
+
## 7. Deploy
227
219
228
220
Run [`npx wrangler deploy`](/workers/wrangler/commands/#deploy) to deploy your Worker to the Cloudflare global network.
The `DurableObject` base class is an abstract class which all Durable Objects inherit from. This base class provides a set of optional methods, frequently referred to as handler methods, which can respond to events, for example a webSocketMessage when using the [WebSocket Hibernation API](/durable-objects/best-practices/websockets/#websocket-hibernation-api). To provide a concrete example, here is a Durable Object `MyDurableObject` which extends `DurableObject` and implements the fetch handler to return "Hello, World!" to the calling Worker.
10
+
The `DurableObject` base class is an abstract class which all Durable Objects inherit from. This base class provides a set of optional methods, frequently referred to as handler methods, which can respond to events, for example a webSocketMessage when using the [WebSocket Hibernation API](/durable-objects/features/websockets/#websocket-hibernation-api). To provide a concrete example, here is a Durable Object `MyDurableObject` which extends `DurableObject` and implements the fetch handler to return "Hello, World!" to the calling Worker.
11
11
12
12
<TypeScriptExample>
13
13
```ts
@@ -87,4 +87,4 @@ A list of bindings which are available to the Durable Object.
87
87
88
88
## Related resources
89
89
90
-
- Refer to [Use WebSockets](/durable-objects/best-practices/websockets/) for more information on examples of WebSocket methods and best practices.
90
+
- Refer to [Use WebSockets](/durable-objects/features/websockets/) for more information on examples of WebSocket methods and best practices.
Copy file name to clipboardExpand all lines: src/content/docs/durable-objects/api/sql-storage.mdx
+7-5Lines changed: 7 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
---
2
-
title: SQL Storage
2
+
title: SQL storage
3
3
pcx_content_type: concept
4
4
sidebar:
5
-
order: 6
5
+
order: 7
6
6
7
7
---
8
8
@@ -33,12 +33,12 @@ export class MyDurableObject extends DurableObject {
33
33
}
34
34
```
35
35
36
-
:::note[SQLite in Durable Objects Beta]
36
+
:::note[SQLite in Durable Objects]
37
37
SQL API methods accessed with `ctx.storage.sql` are only allowed on [Durable Object classes with SQLite storage backend](/durable-objects/reference/durable-objects-migrations/#enable-sqlite-storage-backend-on-new-durable-object-class-migration) and will return an error if called on Durable Object classes with a key-value storage backend.
38
38
:::
39
39
40
40
:::note[Writing to indexes or virtual tables]
41
-
When writing data, every index counts as an additional row. However, indexes may be beneficial for read-heavy use cases. Refer to [Index for SQLite Durable Objects](/durable-objects/best-practices/access-durable-objects-storage/#index-for-sqlite-durable-objects).
41
+
When writing data, every index counts as an additional row. However, indexes may be beneficial for read-heavy use cases. Refer to [Index for SQLite Durable Objects](/durable-objects/features/access-durable-objects-storage/#index-for-sqlite-durable-objects).
42
42
43
43
Writing data to [SQLite virtual tables](https://www.sqlite.org/vtab.html) also counts towards rows written.
44
44
:::
@@ -47,6 +47,8 @@ Specifically for Durable Object classes with SQLite storage backend, KV operatio
@@ -161,7 +163,7 @@ Providing a type parameter does _not_ validate that the query result matches you
161
163
162
164
Your type must conform to the shape of a TypeScript [Record](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type) type representing the name (`string`) of the column and the type of the column. The column type must be a valid `SqlStorageValue`: one of `ArrayBuffer | string | number | null`.
Copy file name to clipboardExpand all lines: src/content/docs/durable-objects/api/state.mdx
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,11 +106,11 @@ export class MyDurableObject extends DurableObject {
106
106
107
107
### `acceptWebSocket`
108
108
109
-
`acceptWebSocket` is part of the [WebSocket Hibernation API](/durable-objects/best-practices/websockets/#websocket-hibernation-api), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.
109
+
`acceptWebSocket` is part of the [WebSocket Hibernation API](/durable-objects/features/websockets/#websocket-hibernation-api), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.
110
110
111
111
`acceptWebSocket` adds a WebSocket to the set of WebSockets attached to the Durable Object. Once called, any incoming messages will be delivered by calling the Durable Object's `webSocketMessage` handler, and `webSocketClose` will be invoked upon disconnect. After calling `acceptWebSocket`, the WebSocket is accepted and its `send` and `close` methods can be used.
112
112
113
-
The [WebSocket Hibernation API](/durable-objects/best-practices/websockets/#websocket-hibernation-api) takes the place of the standard [WebSockets API](/workers/runtime-apis/websockets/). Therefore, `ws.accept` must not have been called separately and `ws.addEventListener` method will not receive events as they will instead be delivered to the Durable Object.
113
+
The [WebSocket Hibernation API](/durable-objects/features/websockets/#websocket-hibernation-api) takes the place of the standard [WebSockets API](/workers/runtime-apis/websockets/). Therefore, `ws.accept` must not have been called separately and `ws.addEventListener` method will not receive events as they will instead be delivered to the Durable Object.
114
114
115
115
The WebSocket Hibernation API permits a maximum of 32,768 WebSocket connections per Durable Object, but the CPU and memory usage of a given workload may further limit the practical number of simultaneous connections.
116
116
@@ -125,7 +125,7 @@ The WebSocket Hibernation API permits a maximum of 32,768 WebSocket connections
125
125
126
126
### `getWebSockets`
127
127
128
-
`getWebSockets` is part of the [WebSocket Hibernation API](/durable-objects/best-practices/websockets/#websocket-hibernation-api), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.
128
+
`getWebSockets` is part of the [WebSocket Hibernation API](/durable-objects/features/websockets/#websocket-hibernation-api), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.
129
129
130
130
`getWebSockets` returns an `Array<WebSocket>` which is the set of WebSockets attached to the Durable Object. An optional tag argument can be used to filter the list according to tags supplied when calling [`DurableObjectState::acceptWebSocket`](/durable-objects/api/state/#acceptwebsocket).
131
131
@@ -145,7 +145,7 @@ Disconnected WebSockets are not returned by this method, but `getWebSockets` may
145
145
146
146
### `setWebSocketAutoResponse`
147
147
148
-
`setWebSocketAutoResponse` is part of the [WebSocket Hibernation API](/durable-objects/best-practices/websockets/#websocket-hibernation-api), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.
148
+
`setWebSocketAutoResponse` is part of the [WebSocket Hibernation API](/durable-objects/features/websockets/#websocket-hibernation-api), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.
149
149
150
150
`setWebSocketAutoResponse` sets an automatic response, auto-response, for the request provided for all WebSockets attached to the Durable Object. If a request is received matching the provided request then the auto-response will be returned without waking WebSockets in hibernation and incurring billable duration charges.
151
151
@@ -179,7 +179,7 @@ Disconnected WebSockets are not returned by this method, but `getWebSockets` may
179
179
180
180
### `getWebSocketAutoResponseTimestamp`
181
181
182
-
`getWebSocketAutoResponseTimestamp` is part of the [WebSocket Hibernation API](/durable-objects/best-practices/websockets/#websocket-hibernation-api), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.
182
+
`getWebSocketAutoResponseTimestamp` is part of the [WebSocket Hibernation API](/durable-objects/features/websockets/#websocket-hibernation-api), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.
183
183
184
184
`getWebSocketAutoResponseTimestamp` gets the most recent `Date` on which the given WebSocket sent an auto-response, or null if the given WebSocket never sent an auto-response.
185
185
@@ -193,7 +193,7 @@ Disconnected WebSockets are not returned by this method, but `getWebSockets` may
193
193
194
194
### `setHibernatableWebSocketEventTimeout`
195
195
196
-
`setHibernatableWebSocketEventTimeout` is part of the [WebSocket Hibernation API](/durable-objects/best-practices/websockets/#websocket-hibernation-api), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.
196
+
`setHibernatableWebSocketEventTimeout` is part of the [WebSocket Hibernation API](/durable-objects/features/websockets/#websocket-hibernation-api), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.
197
197
198
198
`setHibernatableWebSocketEventTimeout` sets the maximum amount of time in milliseconds that a WebSocket event can run for.
199
199
@@ -209,7 +209,7 @@ If no parameter or a parameter of `0` is provided and a timeout has been previou
209
209
210
210
### `getHibernatableWebSocketEventTimeout`
211
211
212
-
`getHibernatableWebSocketEventTimeout` is part of the [WebSocket Hibernation API](/durable-objects/best-practices/websockets/#websocket-hibernation-api), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.
212
+
`getHibernatableWebSocketEventTimeout` is part of the [WebSocket Hibernation API](/durable-objects/features/websockets/#websocket-hibernation-api), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.
213
213
214
214
`getHibernatableWebSocketEventTimeout` gets the currently set hibernatable WebSocket event timeout if one has been set via [`DurableObjectState::setHibernatableWebSocketEventTimeout`](/durable-objects/api/state/#sethibernatablewebsocketeventtimeout).
215
215
@@ -223,7 +223,7 @@ If no parameter or a parameter of `0` is provided and a timeout has been previou
223
223
224
224
### `getTags`
225
225
226
-
`getTags` is part of the [WebSocket Hibernation API](/durable-objects/best-practices/websockets/#websocket-hibernation-api), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.
226
+
`getTags` is part of the [WebSocket Hibernation API](/durable-objects/features/websockets/#websocket-hibernation-api), which allows a Durable Object to be removed from memory to save costs while keeping its WebSockets connected.
227
227
228
228
`getTags` returns tags associated with a given WebSocket. This method throws an exception if the WebSocket has not been associated with the Durable Object via [`DurableObjectState::acceptWebSocket`](/durable-objects/api/state/#acceptwebsocket).
0 commit comments