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/changelog/durable-objects/2025-04-07-durable-objects-free-tier.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ products:
7
7
date: 2025-04-07T06:00:00Z
8
8
---
9
9
10
-
Durable Objects can now be used with zero commitment on the [Workers Free plan](/workers/platform/pricing/) allowing you to build AI agents with [Agents SDK](/agents), collaboration tools, and real-time applications like chat or multiplayer games.
10
+
Durable Objects can now be used with zero commitment on the [Workers Free plan](/workers/platform/pricing/) allowing you to build AI agents with [Agents SDK](/agents/), collaboration tools, and real-time applications like chat or multiplayer games.
11
11
12
12
Durable Objects let you build stateful, serverless applications with millions of tiny coordination instances that run your application code alongside (in the same thread!) your durable storage. Each Durable Object can access its own SQLite database through a [Storage API](/durable-objects/best-practices/access-durable-objects-storage/). A Durable Object class is defined in a Worker script encapsulating the Durable Object's behavior when accessed from a Worker. To try the code below, click the button:
Copy file name to clipboardExpand all lines: src/content/changelog/durable-objects/2025-04-07-sqlite-in-durable-objects-ga.mdx
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
title: SQLite in Durable Objects GA
3
-
description: SQLite-bakced Durable Objects are generally available.
3
+
description: SQLite-backed Durable Objects are generally available.
4
4
products:
5
5
- durable-objects
6
6
- workers
@@ -9,7 +9,7 @@ date: 2025-04-07T06:00:00Z
9
9
10
10
SQLite in Durable Objects is now generally available (GA). Since the [public beta](https://blog.cloudflare.com/sqlite-in-durable-objects/) in September 2024, we've added feature parity and robustness for the SQLite storage backend compared to the preexisting key-value (KV) storage backend for Durable Objects.
11
11
12
-
SQLite-backed Durable Objects are recommended for all new Durable Object classes, using `new_sqlite_classes`[Wrangler configuration](/durable-objects/best-practices/access-durable-objects-storage/#create-sqlite-backed-durable-object-class). Only SQLite-backed Durable Objects have access to Storage API's [SQL](/durable-objects/api/storage-api/#sql-api) and [point-in-time recovery](/durable-objects/api/storage-api/#pitr-point-in-time-recovery-api) methods, which provide relational data modelling, SQL querying, and better data management.
12
+
SQLite-backed Durable Objects are recommended for all new Durable Object classes, using `new_sqlite_classes`[Wrangler configuration](/durable-objects/best-practices/access-durable-objects-storage/#create-sqlite-backed-durable-object-class). Only SQLite-backed Durable Objects have access to Storage API's [SQL](/durable-objects/api/storage-api/#sql-api) and [point-in-time recovery](/durable-objects/api/storage-api/#pitr-point-in-time-recovery-api) methods, which provide relational data modeling, SQL querying, and better data management.
13
13
14
14
```js
15
15
exportclassMyDurableObjectextendsDurableObject {
@@ -21,7 +21,7 @@ export class MyDurableObject extends DurableObject {
Copy file name to clipboardExpand all lines: src/content/docs/durable-objects/api/storage-api.mdx
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,11 +67,11 @@ export class Counter extends DurableObject {
67
67
```
68
68
</TypeScriptExample>
69
69
70
-
JavaScript is a single-threaded and event-driven programming language. This means that JavaScript runtimes, by default, allow requests to interleave with each other which can lead to concurrency bugs. The Durable Objects runtime uses a combination of <GlossaryTooltipterm="input gate">input gates</GlossaryTooltip> and <GlossaryTooltipterm="output gate">output gates</GlossaryTooltip> to avoid this type of concurrency bug when performing storage operations. Learn more with our [blog post](https://blog.cloudflare.com/durable-objects-easy-fast-correct-choose-three/)
70
+
JavaScript is a single-threaded and event-driven programming language. This means that JavaScript runtimes, by default, allow requests to interleave with each other which can lead to concurrency bugs. The Durable Objects runtime uses a combination of <GlossaryTooltipterm="input gate">input gates</GlossaryTooltip> and <GlossaryTooltipterm="output gate">output gates</GlossaryTooltip> to avoid this type of concurrency bug when performing storage operations. Learn more in our [blog post](https://blog.cloudflare.com/durable-objects-easy-fast-correct-choose-three/).
71
71
72
72
## SQL API
73
73
74
-
The `SqlStorage` interface encapsulates methods that modify the SQLite database embedded within a Durable Object. The `SqlStorage` interface is accessible via the [`sql` property](/durable-objects/api/storage-api/#) of `DurableObjectStorage` class.
74
+
The `SqlStorage` interface encapsulates methods that modify the SQLite database embedded within a Durable Object. The `SqlStorage` interface is accessible via the [`sql` property](/durable-objects/api/storage-api/#sql) of `DurableObjectStorage` class.
75
75
76
76
For example, using `sql.exec()`, a user can create a table, then insert rows into the table.
* The column names of the query in the order they appear in each row array returned by the `raw` iterator.
@@ -186,7 +186,7 @@ let size = ctx.storage.sql.databaseSize;
186
186
187
187
For [SQLite-backed Durable Objects](/durable-objects/best-practices/access-durable-objects-storage/#create-sqlite-backed-durable-object-class), the following point-in-time-recovery (PITR) API methods are available to restore a Durable Object's embedded SQLite database to any point in time in the past 30 days. These methods apply to the entire SQLite database contents, including both the object's stored SQL data and stored key-value data using the key-value `put()` API. The PITR API is not supported in local development because a durable log of data changes is not stored locally.
188
188
189
-
The PITR API represents points in times using 'bookmarks'. A bookmark is a mostly alphanumeric string like `0000007b-0000b26e-00001538-0c3e87bb37b3db5cc52eedb93cd3b96b`. Bookmarks are designed to be lexically comparable: a bookmark representing an earlier point in time compares less than one representing a later point, using regular string comparison.
189
+
The PITR API represents points in time using 'bookmarks'. A bookmark is a mostly alphanumeric string like `0000007b-0000b26e-00001538-0c3e87bb37b3db5cc52eedb93cd3b96b`. Bookmarks are designed to be lexically comparable: a bookmark representing an earlier point in time compares less than one representing a later point, using regular string comparison.
190
190
191
191
### `getCurrentBookmark`
192
192
@@ -377,7 +377,7 @@ The `put()` method returns a `Promise`, but most applications can discard this p
377
377
- For Durable Objects with a key-value storage backend, an in-progress `deleteAll()` operation can fail, which may leave a subset of data undeleted. Durable Objects with a SQLite storage backend do not have a partial `deleteAll()` issue because `deleteAll()` operations are atomic (all or nothing).
378
378
-`deleteAll()` does not proactively delete [alarms](/durable-objects/api/alarms/). Use [`deleteAlarm()`](/durable-objects/api/alarms/#deletealarm) to delete an alarm.
@@ -389,7 +389,7 @@ The `put()` method returns a `Promise`, but most applications can discard this p
389
389
390
390
- Provides access to the `put()`, `get()`, `delete()` and `list()` methods documented above to run in the current transaction context. In order to get transactional behavior within a transaction closure, you must call the methods on the `txn` Object instead of on the top-level `ctx.storage` Object.<br/><br/>Also supports a `rollback()` function that ensures any changes made during the transaction will be rolled back rather than committed. After `rollback()` is called, any subsequent operations on the `txn` Object will fail with an exception. `rollback()` takes no parameters and returns nothing to the caller.
391
391
392
-
* When using [the SQLite-backed storage engine](/durable-objects/best-practices/access-durable-objects-storage/#sqlite-storage-backend), the `txn` object is obsolete. Any storage operations performed directly on the `ctx.storage` object, including SQL queries using [`ctx.storage.sql.exec()`](/durable-objects/api/storage-api/#exec), will be considered part of the transaction.
392
+
- When using [the SQLite-backed storage engine](/durable-objects/best-practices/access-durable-objects-storage/#sqlite-storage-backend), the `txn` object is obsolete. Any storage operations performed directly on the `ctx.storage` object, including SQL queries using [`ctx.storage.sql.exec()`](/durable-objects/api/storage-api/#exec), will be considered part of the transaction.
Copy file name to clipboardExpand all lines: src/content/docs/durable-objects/best-practices/access-durable-objects-storage.mdx
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -118,10 +118,10 @@ type User = {
118
118
}
119
119
```
120
120
121
-
This type can then be passed as the type parameter to a `sql.exec` call:
121
+
This type can then be passed as the type parameter to a `sql.exec()` call:
122
122
123
123
```ts
124
-
// The type parameter is passed between the "pointy brackets" before the function argument:
124
+
// The type parameter is passed between angle brackets before the function argument:
125
125
const result =this.ctx.storage.sql.exec<User>("SELECT id, name, email_address, version FROM users WHERE id = ?", user_id).one()
126
126
// result will now have a type of "User"
127
127
@@ -147,7 +147,8 @@ for (let row of cursor) {
147
147
}
148
148
```
149
149
150
-
You can represent the shape of any result type you wish, including more complex types. If you are performing a JOIN across multiple tables, you can compose a type that reflects the results of your queries.
150
+
You can represent the shape of any result type you wish, including more complex types. If you are performing a
151
+
`JOIN` across multiple tables, you can compose a type that reflects the results of your queries.
Copy file name to clipboardExpand all lines: src/content/docs/durable-objects/best-practices/websockets.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ import { Tabs, TabItem, GlossaryTooltip, Type } from "~/components";
9
9
10
10
This guide covers how to use Durable Objects as WebSocket servers that can connect thousands of clients (per instance), as well as a WebSocket client to connect to other servers or even Durable Objects.
11
11
12
-
There are two sets of WebSockets API
12
+
There are two sets of WebSockets API:
13
13
14
14
1. Native Durable Object WebSocket API, which allows your Durable Object to hibernate without disconnecting clients when not actively doing work **(recommended)**.
15
15
2. Web Standard WebSocket APIs, using the familiar `addEventListener` event pattern.
Copy file name to clipboardExpand all lines: src/content/docs/durable-objects/platform/pricing.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ Durable Objects can incur two types of billing: compute and storage.
18
18
These examples exclude the costs for the Workers calling the Durable Objects. When modelling the costs of a Durable Object, note that:
19
19
20
20
* Inactive objects receiving no requests do not incur any duration charges.
21
-
* The [WebSocket Hibernation API](/durable-objects/best-practices/websockets#websocket-hibernation-api) can dramatically reduce duration-related charges for Durable Objects communicating with clients over the WebSocket protocol, especially if messages are only transmitted occasionally at sparse intervals.
21
+
* The [WebSocket Hibernation API](/durable-objects/best-practices/websockets/#websocket-hibernation-api) can dramatically reduce duration-related charges for Durable Objects communicating with clients over the WebSocket protocol, especially if messages are only transmitted occasionally at sparse intervals.
Copy file name to clipboardExpand all lines: src/content/docs/durable-objects/reference/environments.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,7 +65,7 @@ durable_objects.bindings = [
65
65
66
66
Local development sessions create a standalone, local-only environment that mirrors the production environment, so that you can test your Worker and Durable Objects before you deploy to production.
67
67
68
-
An existing Durable Object binding of DB would be available to your Worker when running locally.
68
+
An existing Durable Object binding of `DB` would be available to your Worker when running locally.
69
69
70
70
Refer to Workers [Local development](/workers/local-development/#supported-resource-bindings-in-different-environments).
Copy file name to clipboardExpand all lines: src/content/partials/durable-objects/durable-objects-pricing.mdx
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ await durableObjectStub.cat(); // billed as a request
36
36
37
37
<sup>3</sup> Application level auto-response messages handled by [`state.setWebSocketAutoResponse()`](/durable-objects/best-practices/websockets/) will not incur additional wall-clock time, and so they will not be charged.
38
38
39
-
<sup>4</sup> Duration is billed in wall-clock time as long as the Object is active, but is shared across all requests active on an Object at once. Calling `accept()` on a WebSocket in an Object will incur duration charges for the entire time the WebSocket is connected. Note that the request context for a Durable Object extends for 10 seconds after the last client disconnects. The request context of a Durable Object is evaluated every 70 seconds and the context is ended if it has been active for 70 seconds. If you prefer, use the [WebSocket hibernation API](/durable-objects/best-practices/websockets/#websocket-hibernation-api) to avoid incurring duration charges once all event handlers finish running.
39
+
<sup>4</sup> Duration is billed in wall-clock time as long as the Object is active, but is shared across all requests active on an Object at once. Calling `accept()` on a WebSocket in an Object will incur duration charges for the entire time the WebSocket is connected. Note that the request context for a Durable Object extends for 10 seconds after the last client disconnects. The request context of a Durable Object is evaluated every 70 seconds and the context is ended if it has been active for 70 seconds. If you prefer, use the [WebSocket Hibernation API](/durable-objects/best-practices/websockets/#websocket-hibernation-api) to avoid incurring duration charges once all event handlers finish running.
40
40
41
41
<sup>5</sup> Duration billing charges for the 128 MB of memory your Durable Object is allocated, regardless of actual usage. If your account creates many instances of a single Durable Object class, Durable Objects may run in the same isolate on the same physical machine and share the 128 MB of memory. These Durable Objects are still billed as if they are allocated a full 128 MB of memory.
42
42
@@ -45,7 +45,7 @@ await durableObjectStub.cat(); // billed as a request
The [Durable Objects Storage API](/durable-objects/api/storage-api) is only accessible from within Durable Objects. Pricing depends on the type of storage your Durable Objects use.
48
+
The [Durable Objects Storage API](/durable-objects/api/storage-api/) is only accessible from within Durable Objects. Pricing depends on the type of storage your Durable Objects use.
49
49
50
50
-**SQLite-backed Durable Objects (recommended)**: This is the recommended storage for new Durable Object classes. Workers Free plan can only create and access SQLite-backed Durable Objects.
51
51
-**Key-value storage backed Durable Objects**: This is only available on the Workers Paid plan.
@@ -69,7 +69,7 @@ The [Durable Objects Storage API](/durable-objects/api/storage-api) is only acce
69
69
70
70
<sup>3</sup> Each `setAlarm()` is billed as a single row written.
71
71
72
-
<sup>4</sup> Deletes are counted as rows_written.
72
+
<sup>4</sup> Deletes are counted as rows written.
73
73
74
74
<sup>5</sup> Durable Objects will be billed for stored data until the data is removed. Once the data is removed, the object will be cleaned up automatically by the system.
Copy file name to clipboardExpand all lines: src/content/partials/durable-objects/storage-intro-text.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ The Durable Object Storage API comes with several methods, including [SQL API](/
11
11
12
12
Each method is implicitly wrapped inside a transaction, such that its results are atomic and isolated from all other storage operations, even when accessing multiple key-value pairs.
13
13
14
-
| Type of storage API | SQLitebacked Durable Object | KVbacked Durable Object |
14
+
| Type of storage API | SQLite-backed Durable Object | KV-backed Durable Object |
0 commit comments