How do I work with local D1 in a SvelteKit project?

I've created a new SvelteKit project and can successfully interact with hosted D1 after following the guide https://developers.cloudflare.com/d1/examples/d1-and-sveltekit/. Using pnpm dev to launch the SvelteKit local dev environment as standard works for the hosted D1.

However I would like to develop locally also. The guide advises to pass --d1 BINDING_NAME=DATABASE_ID to wrangler dev (e.g., npx wrangler dev --d1 DB=example-uuid-here) but this results in ✘ [ERROR] Unknown argument: d1 (which aligns with wrangler's docs https://developers.cloudflare.com/workers/wrangler/commands/#dev, no d1 option exists)

I have the following config:
# wrangler.toml
name = "example"
compatibility_date = "2024-04-23"

[[d1_databases]]
binding = "DB"
database_name = "example-prod"
database_id = "example-uuid-here"

If I run npx wrangler dev I receive: ✘ [ERROR] Missing entry-point: The entry-point should be specified via the command line (e.g. wrangler dev path/to/script) or the main config field.
Cloudflare Docs
SvelteKit is a full-stack framework that combines the Svelte front-end framework with Vite for server-side capabilities and rendering. You can query
Cloudflare Docs
Create, develop, and deploy your Cloudflare Workers with Wrangler commands.
Was this page helpful?