sincecutoff.com
← all changes

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 dev

WHY 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

Check the installed version and the source before using it. Entry JSON

Report a problem with this card