Cloudflare D1
Cloudflare D1 is the serverless SQLite database of Cloudflare Workers. DevDb opens local and remote D1 databases.
| Database | Where DevDb finds it | License |
|---|---|---|
| D1 (local) | wrangler.json, wrangler.jsonc or wrangler.toml with d1_databases | Free |
| D1 (remote) | Remote connection: account ID, database ID and API token | Pro |
D1 (local)
wrangler dev and wrangler d1 ... --local keep a local SQLite copy of each D1 database. DevDb opens these files with zero-config detection.
DevDb:
- Reads the
d1_databasesbindings fromwrangler.json,wrangler.jsoncorwrangler.toml. - Looks for the local file of each binding in
.wrangler/state/v3/d1/miniflare-D1DatabaseObject/. - Also looks in the
--persist-tofolder, if a script inpackage.jsonsets one.
Each binding shows under Local Databases as Cloudflare D1 (local) — <binding> binding. DevDb also lists local files that no binding maps to.
No local database yet
If a binding has no local file, DevDb tells you to create it. Run one of these commands, then refresh DevDb:
wrangler d1 migrations apply <database> --local
wrangler devChanges in DevDb go to the local file only. They do not change the remote database.
D1 (remote)
ProDevDb connects to a D1 database in your Cloudflare account through the Cloudflare REST API.
- Under Remote Connections, click Add, then select Cloudflare D1.
- Enter the details:
| Field | Description |
|---|---|
| Account ID | Your Cloudflare account ID |
| Database ID | The database_id of the D1 database. DevDb offers the database_id values from your Wrangler configuration. |
| API Token | A Cloudflare API token with D1 permission |
- Click Test, then click Connect.
API token permission
| Permission | Access |
|---|---|
| D1 Read | Read-only |
| D1 Edit | Read and change data |
Use D1 Read when you only look at data. DevDb keeps the token in the secret storage of your editor.
WARNING
Remote D1 is your deployed data. Changes in DevDb change the data that your Worker uses.
MCP
MCP queries on D1 are read-only unless Devdb.mcp.allowWrites is on.