Skip to content

Demonstration of an issue with Cloudflare D1 in a SvelteKit app

License

Notifications You must be signed in to change notification settings

martindisch/d1-sveltekit-repro

Repository files navigation

d1-sveltekit-repro

Demonstration of an issue with Cloudflare D1 in a SvelteKit app.

Update 2023-02-22

It actually works now with the --bundle flag. Run wrangler pages publish .svelte-kit/cloudflare --bundle to try it.

Repro

  1. Make sure you have wrangler installed locally and are logged in.
  2. Install dependencies with npm install.
  3. Create a D1 DB with wrangler d1 create d1-sveltekit-repro-db.
  4. Create a KV namespace with wrangler kv:namespace create kv. This is used as a smoke test to prove that bindings in general do work.
  5. Run a build with npm run build.
  6. Create the pages project with wrangler pages publish .svelte-kit/cloudflare.
  7. Configure the production bindings for your project in the Cloudflare dashboard.
    • KV namespace binding: KV=d1-sveltekit-repro-kv
    • D1 database binding: DB=d1-sveltekit-repro-db
  8. Publish again to trigger a new deployment that has access to the bindings with wrangler pages publish .svelte-kit/cloudflare.

Now you can check the three different API routes to see what works and doesn't (change the domain to your project).

License

MIT License

About

Demonstration of an issue with Cloudflare D1 in a SvelteKit app

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published