Skip to content
Engineering

Deploy target beats framework, SvelteKit on Cloudflare Workers for Platforms

BYOB Team

BYOB Team

Updated:
11 min read

Framework choice matters less than where code runs. BYOB ships SvelteKit on Cloudflare with static pages prerendered to the CDN and only dash plus API on edge functions, while user projects run isolated on Workers for Platforms. Target first, framework second.

Key takeaways

  • • Teams argue framework while the target decides the bill
  • • Our route table prerenders content to CDN and runs only auth plus API at the edge
  • • User projects stay isolated on Workers for Platforms with KV domain map
  • • D1 plus Supabase splits per project data from control plane
Deploy target beats framework, SvelteKit on Cloudflare Workers for Platforms

Why should you pick the deploy target before the framework? #

Deploy target decides cost, cold starts, and tenancy; BYOB ships SvelteKit on Cloudflare Workers for Platforms with content prerendered to CDN, dash plus API as edge functions, and user projects isolated as platform workers with a KV domain map. Scope: SaaS teams in BYOB shipping content plus auth plus API pockets. D1 holds per-project edge data while Supabase holds control-plane auth plus billing.

Framework threads run hot and decide little. React or Svelte will both render your hero. What decides your bill, your cold starts, your tenancy model, and your 3am pages is where the code runs and how traffic finds it.

Our answer is boring on purpose. SvelteKit compiled to the edge, content prerendered to CDN, auth plus API as functions, user projects isolated as platform workers, data split between D1 at the edge and Supabase at the core. Target first, framework second, drama never.

How is our route table split? #

The Svelte config says it plainly. Adapter cloudflare with routes include for dash plus API, exclude for files plus blog plus tools plus prompts plus quiz and the rest. Layout prerenders by default, dash opts into auto. That split is the whole cost story.

Content routes build once and serve from CDN. Crawlers get instant HTML, users get cache hits, we pay no invocation per read. Only signed in paths and API routes burn edge compute. A commented out static adapter import sits above the cloudflare import, marking the choice as deliberate rather than accidental.

flowchart LR A[Request] --> B{Route kind?} B -->|blog tools docs| C[Prerendered CDN HTML] B -->|dash api| D[Edge function] B -->|user project host| E[Dispatch worker] E --> F[Project worker plus D1]
✨
TIP

Try it: Deploy Checklist — it catches route-split mistakes before they burn edge compute here.

Try it right here: deploy checklistOpen full tool

Loading the interactive tool… or open it here.

Layer Where it runs Why
Blog plus tools plus docs Prerendered CDN Instant crawl, no per read cost
Dash plus API Edge functions Auth plus live data need compute
User projects Platform workers Full isolation, no origin hop
Custom domains KV domain map plus dispatcher Hostname to worker lookup at edge
Per project data D1 at edge Thousands of DBs, no pooling pain
Control plane Supabase Postgres Auth plus billing plus projects

Why do user projects never touch our origin? #

The dispatcher worker owns the project zone. Root maps to the marketing site, reserved names get 403, everything else resolves through KV. Byob hostnames map to slugs directly, custom hostnames map through a domain entry, canonical checks redirect when a custom domain is active, then the request fetches from the named project worker.

Traefik never sees that traffic. Our proxy handles control plane hosts for prim plus air APIs, while project traffic stays on the edge from first byte to last. Scale comes from the platform, not from boxes we babysit. The tradeoff is eventual consistency on KV writes, so a reconciler keeps custom domains in sync, and debug moves to worker tooling.

What does the split cost in upkeep? #

Two small taxes. The route exclude list must grow with every new content section or pages silently burn compute. KV writes need a reconciler because reads are eventually consistent. Both are cheap when owned in code and painful when forgotten, so we review the list in the same commit that adds the route.

Where do you start once the target is chosen? #

Start with the route table, because everything else hangs off it. List every content path that must prerender to CDN and every signed-in plus API path that needs edge compute, then encode that split in adapter cloudflare routes include plus exclude. Next verify the dispatcher worker: root to marketing, reserved names to 403, platform hosts to slugs, custom hosts through the KV domain map, canonical checks before fetch. Then confirm the data split: per-project D1s for app rows, Supabase for control truth, and a reconciler keeping custom domains in sync. Review the exclude list in the same commit that adds any route.

Who this is for? #

Teams choosing a stack for sites plus apps with user data. If your pages are mostly content with pockets of auth and API, the split above fits. If everything is live per request, budget for more edge compute and keep the same isolation.

  • Best for startups picking a target for content plus auth and API pockets.
  • Best for developers splitting routes between static and edge compute.
  • Best for small teams planning isolation before framework debates.

What we learned building this? #

The route exclude list is a living doc. Every new content section must join it or it silently burns compute. We learned to review that list in the same commit that adds the route. Small discipline, real savings. Framework taste fades, target bills monthly. Choose the target with care and let the framework serve it.

How we picked these

We read our own svelte config plus Cloudflare dispatcher worker plus D1 integration service plus Traefik static routes. We verified route include and exclude lists and dispatch binding names against the files. Framework claims cite official Svelte and Cloudflare docs.

Frequently asked questions

Why SvelteKit instead of Next?

The compiler removes the virtual DOM and ships smaller bundles with built in splitting. Generated code stays readable SvelteKit any developer can extend, and adapter cloudflare maps cleanly to edge plus static

How are routes split?

Blog plus tools plus docs prerender to CDN for instant crawl, only dash plus API run as edge functions. That saves invocation cost while keeping auth paths live

How do user projects stay isolated?

Each project runs as its own worker under a dispatch namespace with a KV domain map for custom hostnames. User traffic never touches our origin

Where does D1 fit versus Supabase?

Per project D1s hold app data at the edge with no pooling pain, Supabase holds control plane plus auth plus storage plus billing. Cheap tenancy plus full platform power

What breaks with this split?

Route exclude lists need discipline and KV writes need a reconciler for custom domains. Debug uses worker tooling rather than plain origin logs

Changelog

  • • Initial publish with svelte config plus dispatcher plus D1 service as evidence
  • • Sep 2026 spam-guard pass - prepended PSB L1 plus added what-next H2, no claim changes

About the Author

BYOB Team

BYOB Team

The creative minds behind BYOB. We're a diverse team of engineers, designers, and AI specialists dedicated to making web development accessible to everyone.

Terms in this guide

Ready to start building?

Join thousands of developers using BYOB to ship faster with AI-powered development.

Get Started Free