wrangler.json supports native Analytics SQL bindings in local development
Introduced 2026-09-30 · score 0.92
HOW TO USE IT
When a Worker uses Analytics SQL during local development, declare `analytics.binding` in `wrangler.json` and run `wrangler dev`; call it through `env.<BINDING>.query()` without `unsafe.bindings`.
{
"analytics": {
"binding": "ANALYTICS"
}
}export default {
async fetch(_request, env) {
const result = await env.ANALYTICS.query({
query: "SELECT COUNT(*) AS requests FROM events.httpRequests",
});
return Response.json(result);
},
};wrangler devWHY THIS HELPS
During local development of a Worker that uses an Analytics SQL binding, configure the binding and call it with `wrangler dev`.
REQUIREMENTS AND LIMITATIONS
- Version: 4.145.0
- analytics.binding (required): Name used to access the Analytics SQL binding on the Worker `env` object.
- query (required): One SQL `SELECT` statement; use `$1` or `$name` for parameter placeholders.
- Prerequisite: Wrangler 4.145.0 or later.
- Prerequisite: Analytics SQL has no local implementation; the binding always connects to the remote service during local development.
FIRST-PARTY EVIDENCE
- https://github.com/cloudflare/workers-sdk/releases/tag/wrangler%404.145.0
- https://developers.cloudflare.com/workers/runtime-apis/bindings/analytics-sql/
- https://developers.cloudflare.com/workers/wrangler/commands/workers/
- https://developers.cloudflare.com/workers/wrangler/configuration/
Check the installed version and the source before using it. Entry JSON