wrangler web_search binding and ad hoc CLI search
Introduced 2026-06-01 · score 0.98
HOW TO USE IT
When adding web discovery to a Worker, declare the `web_search` binding and call its `search()` method; use global `fetch()` with a result URL to read content. For a one-off query, run the Wrangler `websearch search` command with optional `--limit` or `--json`.
{"web_search": {"binding": "WEBSEARCH"}}npx wrangler websearch search "cloudflare workers" --limit 5npx wrangler websearch search "cloudflare workers" --jsonWHY THIS HELPS
Add web discovery to a Worker or run a one-off search while developing it.
REQUIREMENTS AND LIMITATIONS
- Version: 4.96.0
- web_search.binding (required): Binding variable name available to Worker code; the example uses `WEBSEARCH`.
- search() query (required): Query searched by the binding; returns URLs and catalog metadata.
- --limit <number>: Maximum results; defaults to 10 and is capped at 20.
- --json: Print the raw response instead of a pretty table.
- Prerequisite: Wrangler login adds the `websearch.run` OAuth scope.
- Prerequisite: The binding connects remotely during local development through Miniflare’s remote-bindings transport.
- The shared corpus is singular; no namespace, instance, or other field is specified, only the variable name.
- The binding is always remote in local development: Miniflare proxies to the production Web Search service via remote-bindings transport.
- Web Search is discovery-only; invoke global `fetch()` against a result’s `url` to read its content.
- `--limit` defaults to 10 and is capped at 20.
- Docs conflict: The current Cloudflare Web Search docs describe calling `env.AI.websearch()` with an AI binding; that API differs from the Wrangler 4.96.0 `web_search` binding described in the release note. https://developers.cloudflare.com/web-search/how-to-use/
FIRST-PARTY EVIDENCE
Check the installed version and the source before using it. Entry JSON