Resource Inference
The SDK scans your source files at startup to find the Cloudflare resources you use. When you use a resource in code, the SDK creates the matching binding for local dev. Most projects need no manual config.
On this pageSee which imports turn on which bindings · Understand how detection works · Override detection when you need to
Detected bindings
| Binding | Type | Detected by import | Detected by env access |
|---|---|---|---|
DB | D1Database | import { db } from "void/db" | env.DB or c.env.DB |
KV | KVNamespace | import { kv } from "void/kv" | env.KV or c.env.KV |
STORAGE | R2Bucket | import { storage } from "void/storage" | env.STORAGE or c.env.STORAGE |
AI | Ai | import { ai } from "void/ai" | env.AI or c.env.AI |
SANDBOX | Managed Sandbox capability | import { getSandbox } from "void/sandbox" | getSandbox(); native Cloudflare also exposes env.SANDBOX / c.env.SANDBOX |
| Auth | none | import { ... } from "void/auth" or import { auth } from "void/client" / void/client/react / void/client/vue / void/client/svelte / void/client/solid | none |
QUEUE_* | Queue | import { queues } from "void/queues" | env.QUEUE_* |
VOID_LIVE | DurableObjectNamespace | import { defineLiveStream } from "void/live" | n/a |
| filename-derived | DurableObjectNamespace | A default-exported defineDurableState() module in durable-objects/ | n/a |
Auth is also detected when you import auth from void/client or a framework client subpath such as void/client/react. Importing only fetch does not count.
Durable state is inferred from files in durable-objects/. For example, durable-objects/shopping-cart.ts creates the SHOPPING_CART binding. It also exports ShoppingCartDurableObject and records its migration. See Durable State.
Scanned directories
Standard mode
Native SDK apps scan these folders by default. If you set sourceDir, the SDK scans that folder instead:
| Directory | Contains |
|---|---|
routes/ | API route handlers |
middleware/ | Hono middleware |
queues/ | Queue consumers |
pages/ | Page components and .server.ts companions |
crons/ | Scheduled job handlers |
email/ | Inbound email handlers |
src/ | Application source |
Framework mode
For supported meta-frameworks, the SDK scans these folders:
| Directory | Contains |
|---|---|
src/ | Application source |
app/ | Framework app directory |
routes/ | Framework routes |
server/ | Server-side code |
pages/ | Framework pages |
crons/ | Scheduled job handlers |
queues/ | Queue consumers |
The SDK detects the framework from package.json dependencies and dev dependencies. Add voidPlugin() to the framework's Vite config to turn on inference in dev. Each integration guide shows the setup.
Always scanned
These are checked in every mode:
- SSR entry, such as
src/main.ssr.ts, for SSR apps that read bindings while rendering - App source in
src/or yoursourceDir, including resource and auth imports durable-objects/, for typed Durable Object state modules in native SDK apps
Custom scan directories
If your code lives in other folders, set the folders to scan:
{
"inference": {
"scanDirs": ["src", "lib", "workers"]
}
}Paths are relative to the project root. inference.scanDirs fully replaces the default folders. The SSR entry and app source are still scanned.
Explicit binding overrides
Use inference.bindings to turn on, turn off or rename a binding when inference gets it wrong. It only overrides the bindings you name. The rest are still inferred.
File types
Inference scans .ts, .tsx, .mts, .js, .jsx, .mjs and Astro frontmatter. Put server resource imports in these files or in a page's .server.ts companion. Vue and Svelte component files are not scanned.