sveltekit-cloudflare-do Svelte Themes

Sveltekit Cloudflare Do

2025-11 SvelteKit + Cloudflare Durable Object via Service Binding

SvelteKit - Cloudflare Durable Object

As of 2025 November, developing SvelteKit with Cloudflare Durable Object is non-trivial due to several limitations:

  1. @sveltejs/adapter-cloudfare does not allow exporting anything else other than the default worker entry point (fetch handler). See https://github.com/sveltejs/kit/issues/1712 for more details.
  2. Durable Object RPC calls do not work cross-worker during development with getPlatformProxy. See https://github.com/cloudflare/workers-sdk/issues/9445 for more details.

Thus, our best bet is to have a separate worker that proxies Durable Object methods via Cloudflare's Service binding API. This repo demonstrates exactly that.

Prerequisites

pnpm. Install via volta is recommended.

Development

  1. Install dependencies (at project root):

    pnpm install
    
  2. Start worker dev server:

    cd worker
    pnpm dev
    
  3. Start SvelteKit dev server:

    cd sveltekit
    pnpm dev
    

Open SvelteKit at http://localhost:517X should yield output from Durable Object. Data flow is as follows:

  1. src/routes/+page.server.ts: calls worker RPC method via the WORKER service binding (see sveltekit/wrangler.jsonc).
  2. worker/src/worker.ts: worker service binding calls RPC method on Durable Object.

Top categories

Loading Svelte Themes