Skip to content
AnswerWell geo Documentation

Research · 7 min read · Answerwell

Local Development Test: Dev Server, Bindings, and Verification

How to start Wrangler and Vite local dev, test Workers on localhost, use bindings, and confirm integrations before deploy.

This page summarizes Cloudflare’s documentation on local development for Workers, Pages, AI Search, Workflows, D1, and related tutorials. The same pattern appears across dozens of guides: start a local server, hit http://localhost:8787 (or the port Wrangler prints), and confirm behavior with a browser or curl before you deploy.

wrangler dev: how to start a local Worker dev server

Section titled “wrangler dev: how to start a local Worker dev server”

wrangler dev is the main way to run a Worker on your machine while you edit code. Cloudflare describes it as establishing a connection between localhost and the development runtime so you can test with full access to platform bindings.

wrangler dev is a command that establishes a connection between localhost and a global network server that operates your Worker in development. A cloudflared tunnel forwards all requests to the global network server, which continuously updates as your Worker code changes. This allows full access to Workers KV, Durable Objects and other Cloudflare developer platform products. The dev command is a way to test your Worker while developing.

— Cloudflare, Commands — dev

From your project directory, run:

npx wrangler dev

Wrangler listens on http://127.0.0.1:8787 by default (--port changes this). While it runs, HTTP requests to that URL execute your Worker; console.log output and exceptions appear in the terminal. After the Workers get started guide, you open http://localhost:8787, edit src/index.js (or your entry file), save, and reload to see updates.

Many Cloudflare templates wrap the CLI in package scripts. Tutorials variously use npm run dev, yarn run dev, or pnpm run dev for Sandbox SDK, Agents, Analog, SvelteKit-on-Workers, and similar projects. Under the hood, those scripts typically invoke Wrangler or the Cloudflare Vite plugin—the Agents configuration page lists With Vite: npx vite dev and Without Vite: npx wrangler dev.

Entry point Typical use
npx wrangler dev Workers, D1, Workflows, AI bindings, most tutorials
npm run dev Framework and SDK starters (Sandbox, Slack agent, seat booking, etc.)
npx vite dev Full-stack apps with the Cloudflare Vite plugin
npx wrangler pages dev <directory> Pages static assets + Functions (default often http://localhost:8788)
cf dev Deploy your first Worker (cf CLI; default URL may be http://localhost:5173)

For React + Vite on Workers, npm run dev starts Vite; npm run preview runs the build in the Workers runtime to approximate production—see React + Vite.

Local mode, Miniflare, and wrangler dev –remote

Section titled “Local mode, Miniflare, and wrangler dev –remote”

Modern Wrangler uses local mode by default, powered by Miniflare and workerd. D1 local development notes that wrangler dev creates a standalone local environment that mirrors production D1, and that local sessions do not use production data unless you configure remote bindings.

Miniflare starts a local workerd process. This warning applies to default local execution with wrangler dev, vite dev, vite preview, direct Miniflare use, and Miniflare-based testing tools. Setting remote: true on a binding changes which resource your code accesses, but your Worker code still executes locally. By contrast, legacy wrangler dev –remote executes your Worker code on Cloudflare.

— Cloudflare, Dynamic Workers Playground — Running locally

Use wrangler dev --remote when you need the Worker to run on Cloudflare’s network—for example Hyperdrive caching during tests, or Workers VPC with remote VPC services. Workers for Platforms local development describes testing a dispatch Worker locally while user Workers stay deployed.

Queues and Workflows follow the same npx wrangler dev pattern; the console lists simulated bindings such as Queues or Workflows—see Queues local development and Workflows local development.

Test locally: curl, browser, and what “working” looks like

Section titled “Test locally: curl, browser, and what “working” looks like”

Most guides assume you send requests to the URL Wrangler prints (usually port 8787).

D1 + Turso-style Worker — after npx wrangler dev, open /users and /add-user?email=... as in Connect to Turso using Workers.

AI Search (AI SDK) — index then query:

curl http://localhost:8787/setup
curl "http://localhost:8787/?q=How+does+caching+work%3F"

A working flow returns generated text plus a non-empty sources array; empty sources often means indexing is not finished—retry /setup per AI SDK — Test it locally.

Sandbox / code execution — POST JSON to documented paths, for example Build an AI code executor (/execute) or Analyze data with AI (multipart CSV + question).

Workflows and durable agents — POST to start an instance, then poll instanceId:

curl http://localhost:8787
curl "http://localhost:8787?instanceId=abc-123-def"

See Build your first Workflow and Build a Durable AI Agent.

Email Workers — routing uses POST to http://localhost:8787/cdn-cgi/local/email with an RFC 5322 body and Message-ID; sending uses JSON to /—Test email routing locally and Test email sending locally.

Agents, WebSockets, and first-request latency

Section titled “Agents, WebSockets, and first-request latency”

Agents SDK — Test it locally expects a chat client (for example UI with useAgentChat), not plain curl, because AIChatAgent speaks over WebSocket. Success means Wrangler logs show /agents/search-agent/<name>, the search_knowledge_base tool runs, and answers cite seeded content.

Agent Memory get started requires waiting after the first chat (ingestion and indexing take tens of seconds) before a second conversation can recall preferences.

GitHub webhooks and Stream webhooks need a public URL. Test webhooks locally and Build a code review bot use:

npx cloudflared tunnel --url http://localhost:8787

Keep the tunnel running in one terminal and npx wrangler dev in another. Tunnel URLs change when restarted.

Bindings, secrets, and costs during local dev

Section titled “Bindings, secrets, and costs during local dev”

When wrangler dev starts, it prints bindings your Worker can use (D1, KV, Vars, Durable Objects, AI, etc.). If behavior differs from production, compare this list to your wrangler.toml / wrangler.jsonc.

Topic Local behavior
D1 Local DB by default; "remote": true on the binding points at production data (D1 local development)
Hyperdrive localConnectionString hits your DB directly; caching does not apply locally; --remote enables deployed Hyperdrive caching (Hyperdrive get started)
Workers AI Models run against your Cloudflare account and incur usage charges even in local dev (Workers AI with Wrangler)
Secrets / KV .dev.vars for vars; wrangler kv key put ... --local for local KV (Environment variables and secrets)
Containers (Sandbox) Docker engine required; first npm run dev may build images for 2–3 minutes (Sandbox get started)

For Hyperdrive and VPC, misconfigured connection strings or missing auth tokens show up as errors on routes like /users—the Turso tutorial checklist (correct LIBSQL_DB_URL, LIBSQL_DB_AUTH_TOKEN secret) applies the same debugging mindset.

Common mistakes when local development “does not work”

Section titled “Common mistakes when local development “does not work””
  • Wrong port — Pages wrangler pages dev often uses 8788; Hono on Pages docs use http://localhost:8788. Always use the URL Wrangler prints.
  • Expecting instant AI Search / Agent indexing — first /setup or first chat message can take one to two minutes (AI SDK, Agents SDK).
  • Testing Agents with curl only — WebSocket chat agents need a client; logs should show tool calls.
  • Assuming local email actually delivers — local send saves content to files under /tmp/miniflare-... for inspection (Test email sending locally).
  • Code changes invisible in the browser — save the file, confirm wrangler dev is still running, reload (Develop with Wrangler CLI).
  • Using D1 dashboard-only flows — D1 get started notes you cannot develop locally through the dashboard; you need Wrangler.
  • Untrusted code in Miniflare — treat local Worker execution as trusted-dev only (Dynamic Workers Starter).
  1. In the project root, run npx wrangler dev (or the template’s npm run dev) and note the exact localhost URL from the terminal—see Local development — Start a local development server.

  2. Open that URL in a browser or send a curl request to the route your tutorial documents (for example /api/beverages for D1 get started).

  3. Confirm the startup log lists the bindings your Worker uses (D1, KV, Workflows, etc.) and that responses match the tutorial’s sample JSON or HTML.

  4. If the feature depends on the public internet (webhooks), start cloudflared tunnel --url http://localhost:8787 per Test webhooks locally and retest with the tunnel URL.

  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page does not match the official docs or your project behaves differently, email yimasynthetic@gmail.com with the page URL and the exact statement you think is wrong so it can be corrected or clarified.