Skip to content

Commit c30ee9f

Browse files
authored
[DO] FT + SRS GA Docs (#20938)
- Durable Objects on Workers Free - SQLite in Durable Objects GA, 10GB databases
1 parent 8ccd121 commit c30ee9f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+728
-878
lines changed

public/__redirects

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@
399399
/durable-objects/api/hibernatable-websockets-api/ /durable-objects/best-practices/websockets/ 301
400400
/durable-objects/api/alarms-in-durable-objects/ /durable-objects/api/alarms/ 301
401401
/durable-objects/api/websockets/ /durable-objects/best-practices/websockets/ 301
402+
/durable-objects/api/sql-storage/ /durable-objects/api/storage-api/ 301
402403
/durable-objects/platform/data-location/ /durable-objects/reference/data-location/ 301
403404
/durable-objects/platform/environments/ /durable-objects/reference/environments/ 301
404405
/durable-objects/platform/troubleshooting/ /durable-objects/observability/troubleshooting/ 301
@@ -417,7 +418,9 @@
417418
/durable-objects/platform/changelog/ /durable-objects/release-notes/ 301
418419
/durable-objects/changelog/ /durable-objects/release-notes/ 301
419420
/durable-objects/glossary/ /durable-objects/reference/glossary/ 301
420-
/durable-objects/get-started/walkthrough/ /durable-objects/get-started/tutorial/ 301
421+
/durable-objects/get-started/walkthrough/ /durable-objects/get-started/ 301
422+
/durable-objects/get-started/tutorial/ /durable-objects/get-started/ 301
423+
/durable-objects/get-started/tutorial-with-sql-api/ /durable-objects/get-started/ 301
421424
/durable-objects/get-started/video-series/intro/ /durable-objects/video-tutorials/ 301
422425
/durable-objects/get-started/video-series/app-frontend/ /durable-objects/video-tutorials/ 301
423426
/durable-objects/get-started/video-series/deploy-app/ /durable-objects/video-tutorials/ 301
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
title: Durable Objects on Workers Free plan
3+
description: Durable Objects now available on Workers Free plan.
4+
products:
5+
- durable-objects
6+
- workers
7+
date: 2025-04-07T06:00:00Z
8+
---
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.
11+
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:
13+
14+
[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/templates/tree/staging/hello-world-do-template)
15+
16+
```js
17+
import { DurableObject } from "cloudflare:workers";
18+
19+
// Durable Object
20+
export class MyDurableObject extends DurableObject {
21+
...
22+
async sayHello(name) {
23+
return `Hello, ${name}!`;
24+
}
25+
}
26+
27+
// Worker
28+
export default {
29+
async fetch(request, env) {
30+
// Every unique ID refers to an individual instance of the Durable Object class
31+
const id = env.MY_DURABLE_OBJECT.idFromName("foo");
32+
33+
// A stub is a client used to invoke methods on the Durable Object
34+
const stub = env.MY_DURABLE_OBJECT.get(id);
35+
36+
// Methods on the Durable Object are invoked via the stub
37+
const response = await stub.sayHello("world");
38+
39+
return response;
40+
},
41+
};
42+
```
43+
44+
Free plan [limits](/durable-objects/platform/pricing/) apply to Durable Objects compute and storage usage. Limits allow developers to build real-world applications, with every Worker request able to call a Durable Object on the free plan.
45+
46+
For more information, checkout:
47+
- [Documentation](/durable-objects/what-are-durable-objects/)
48+
- [Zero-latency SQLite storage in every Durable Object blog](https://blog.cloudflare.com/sqlite-in-durable-objects/)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: SQLite in Durable Objects GA with 10GB storage per object
3+
description: SQLite-backed Durable Objects are generally available.
4+
products:
5+
- durable-objects
6+
- workers
7+
date: 2025-04-07T06:00:00Z
8+
---
9+
10+
SQLite in Durable Objects is now generally available (GA) with 10GB SQLite database per Durable Object. 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+
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+
14+
```js
15+
export class MyDurableObject extends DurableObject {
16+
sql: SqlStorage
17+
constructor(ctx: DurableObjectState, env: Env) {
18+
super(ctx, env);
19+
this.sql = ctx.storage.sql;
20+
}
21+
22+
async sayHello() {
23+
let result = this.sql
24+
.exec("SELECT 'Hello, World!' AS greeting")
25+
.one();
26+
return result.greeting;
27+
}
28+
}
29+
```
30+
31+
KV-backed Durable Objects remain for backwards compatibility, and a migration path from key-value storage to SQL storage for existing Durable Object classes will be offered in the future.
32+
33+
For more details on SQLite storage, checkout [Zero-latency SQLite storage in every Durable Object blog](https://blog.cloudflare.com/sqlite-in-durable-objects/).

src/content/docs/agents/api-reference/schedule-tasks.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Calling `await this.schedule` returns a `Schedule`, which includes the task's ra
7070

7171
:::note[Maximum scheduled tasks]
7272

73-
Each task is mapped to a row in the Agent's underlying [SQLite database](/durable-objects/api/sql-storage/), which means that each task can be up to 2 MB in size. The maximum number of tasks must be `(task_size * tasks) + all_other_state < maximum_database_size` (currently 1GB per Agent).
73+
Each task is mapped to a row in the Agent's underlying [SQLite database](/durable-objects/api/storage-api/), which means that each task can be up to 2 MB in size. The maximum number of tasks must be `(task_size * tasks) + all_other_state < maximum_database_size` (currently 1GB per Agent).
7474

7575
:::
7676

src/content/docs/agents/api-reference/store-and-sync-state.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ Learn more about the zero-latency SQL storage that powers both Agents and Durabl
227227

228228
:::
229229

230-
The SQL API exposed to an Agent is similar to the one [within Durable Objects](/durable-objects/api/sql-storage/): Durable Object SQL methods available on `this.ctx.storage.sql`. You can use the same SQL queries with the Agent's database, create tables, and query data, just as you would with Durable Objects or [D1](/d1/).
230+
The SQL API exposed to an Agent is similar to the one [within Durable Objects](/durable-objects/api/storage-api/#sql-api): Durable Object SQL methods available on `this.ctx.storage.sql`. You can use the same SQL queries with the Agent's database, create tables, and query data, just as you would with Durable Objects or [D1](/d1/).
231231

232232
### Use Agent state as model context
233233

src/content/docs/browser-rendering/workers-binding-api/browser-rendering-with-DO.mdx

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,15 @@ Create a new Worker project named `browser-worker` by running:
3333
args={"browser-worker"}
3434
/>
3535

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
4537

4638
In your `browser-worker` directory, install Cloudflare’s [fork of Puppeteer](/browser-rendering/platform/puppeteer/):
4739

4840
```sh
4941
npm install @cloudflare/puppeteer --save-dev
5042
```
5143

52-
## 4. Create a R2 bucket
44+
## 3. Create a R2 bucket
5345

5446
Create two R2 buckets, one for production, and one for development.
5547

@@ -68,7 +60,7 @@ wrangler r2 bucket list
6860

6961
After running the `list` command, you will see all bucket names, including the ones you have just created.
7062

71-
## 5. Configure your Wrangler configuration file
63+
## 4. Configure your Wrangler configuration file
7264

7365
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.
7466

@@ -100,13 +92,13 @@ class_name = "Browser"
10092

10193
[[migrations]]
10294
tag = "v1" # Should be unique for each entry
103-
new_classes = ["Browser"] # Array of new classes
95+
new_sqlite_classes = ["Browser"] # Array of new classes
10496

10597
```
10698

10799
</WranglerConfig>
108100

109-
## 6. Code
101+
## 5. Code
110102

111103
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.
112104

@@ -219,11 +211,11 @@ export class Browser {
219211
}
220212
```
221213

222-
## 7. Test
214+
## 6. Test
223215

224216
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.
225217

226-
## 8. Deploy
218+
## 7. Deploy
227219

228220
Run [`npx wrangler deploy`](/workers/wrangler/commands/#deploy) to deploy your Worker to the Cloudflare global network.
229221

0 commit comments

Comments
 (0)