Cloudflare resource bindings
Cloudflare resource bindings declared in the default template's wrangler.jsonc.
The default template configures Cloudflare resources such as D1, KV, R2, Queues, and Durable Objects in wrangler.jsonc. This file is used to generate the CloudflareBindings type in worker-configuration.d.ts. Application code accesses these resources through c.env or WorkerCtx.env.
The saavo-template-* names below come from the template source. When the CLI initializes a project, it updates the D1, R2, Queue, and Worker names to match the project name. Binding identifiers remain unchanged. For example, a project named my-app has a main database named my-app-db, which the code still accesses through c.env.DB.
D1
DB
Prop
Type
The default database name is saavo-template-db. Its initialization script is schema/db-init.sql.
ANALYTICS_DB
Prop
Type
The default database name is saavo-template-analytics-db. Its initialization script is schema/analytics-init.sql.
Neither D1 configuration has a default database_id, so both can only be used for local development. After npm run deploy:init creates the remote databases, the deployment script writes their remote IDs back to wrangler.jsonc.
KV and R2
MAIN_KV
Prop
Type
The template has no remote namespace ID by default. npm run deploy:init adds the id after creating the remote KV namespace.
MAIN_R2
Prop
Type
The default bucket name is saavo-template-storage. It must match the plain variable R2_BUCKET_NAME exactly.
EMAIL
Prop
Type
The template uses Resend by default, so the send_email configuration in wrangler.jsonc is commented out and EMAIL is optional. If you switch to Cloudflare Email, you must uncomment the binding or have the deployment script add it. Make sure the sender address configured in config/base.ts is allowed.
Queue
ASYNC_POLICY_TASK_QUEUE
Prop
Type
The default queue name is saavo-template-policy-task. The consumer processes at most 1 message per batch, with a 5-second batch timeout, a maximum concurrency of 1, and up to 3 retries.
ASYNC_LOGGER_QUEUE
Prop
Type
The default queue name is saavo-template-async-logger. The consumer processes at most 50 messages per batch, with a 5-second batch timeout, a maximum concurrency of 1, and up to 3 retries.
ANALYTICS_QUEUE
Prop
Type
The default queue name is saavo-template-analytics-events. The consumer processes at most 8 messages per batch, with a 5-second batch timeout, a maximum concurrency of 1, and up to 3 retries.
Each queue has both a producer and a consumer configured. ASYNC_POLICY_TASK_QUEUE_NAME, ASYNC_LOGGER_QUEUE_NAME, and ANALYTICS_QUEUE_NAME must each match the corresponding queue name. The queue handler uses these plain variables to identify which queue a message came from.
Durable Object
SAAS_RATE_LIMITER_DO
Prop
Type
SAAS_COUNTER_DO
Prop
Type
SAAS_NONCE_DO
Prop
Type
SAAS_TOKEN_BUCKET_DO
Prop
Type
SAAS_TIMER_DO
Prop
Type
All five Durable Object classes are exported from src/index.tsx. The v1 migration in wrangler.jsonc registers them through new_sqlite_classes.
Default template configuration
| Binding | Resource type | Default resource name |
|---|---|---|
DB | D1 | saavo-template-db |
ANALYTICS_DB | D1 | saavo-template-analytics-db |
MAIN_KV | KV | No resource name specified in wrangler.jsonc |
MAIN_R2 | R2 | saavo-template-storage |
EMAIL | Email Sending | None. The template uses Resend by default. |
ASYNC_POLICY_TASK_QUEUE | Queue | saavo-template-policy-task |
ASYNC_LOGGER_QUEUE | Queue | saavo-template-async-logger |
ANALYTICS_QUEUE | Queue | saavo-template-analytics-events |
SAAS_RATE_LIMITER_DO | Durable Object | RateLimiterDO |
SAAS_COUNTER_DO | Durable Object | CounterDO |
SAAS_NONCE_DO | Durable Object | NonceDO |
SAAS_TOKEN_BUCKET_DO | Durable Object | TokenBucketDO |
SAAS_TIMER_DO | Durable Object | TimerDO |
Update resource names together
When changing an R2 or Queue name, you must also update the resource configuration, producers, consumers, and corresponding plain variables. Changing only one location causes npm run doctor checks to fail and may prevent queue messages from being identified correctly.
After changing wrangler.jsonc, run npm run cf-typegen to regenerate worker-configuration.d.ts. This is a generated file. Do not edit it directly.