Setting the file. One moment.
Subchapter 1.5
references/configuration.mdMarkdown2 KBView on GitHub
Fetch https://developers.cloudflare.com/agents/api-reference/configuration/ (opens in a new tab) for complete documentation.
wrangler.jsonc){
"name": "my-agent",
"main": "src/index.ts",
"compatibility_date": "2025-01-28",
"compatibility_flags": ["nodejs_compat"],
"durable_objects": {
"bindings": [
{ "name": "MyAgent", "class_name": "MyAgent" },
{ "name": "ChatAgent", "class_name": "ChatAgent" }
]
},
"migrations": [
{ "tag": "v1", "new_sqlite_classes": ["MyAgent", "ChatAgent"] }
],
"ai": { "binding": "AI" },
"assets": {
"directory": "./dist/client",
"binding": "ASSETS",
"not_found_handling": "single-page-application",
"run_worker_first": true
}
}new_sqlite_classes migration entrynodejs_compat is requiredv2) for new classesexperimentalDecorators in tsconfig — it breaks @callable"ai": { "binding": "AI", "remote": true } in .dev.vars or configwrangler secret put for secrets, never hardcode themimport { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { cloudflare } from "@cloudflare/vite-plugin";
import { agents } from "agents/vite";
export default defineConfig({
plugins: [react(), cloudflare(), agents()]
});npx wrangler typesThis generates env.d.ts with typed bindings. Regenerate after changing wrangler.jsonc.
Extend the agents tsconfig for correct settings:
{
"extends": ["agents/tsconfig"],
"include": ["src/**/*.ts", "src/**/*.tsx"],
"compilerOptions": { "paths": { "~/*": ["./src/*"] } }
}