Show Menu

Interested in contributing?

Submit Post

Share with the biggest community of Svelte enthusiasts in the world

Welcome to Svelte Society, homepage for everything Svelte. Find what you're looking for in the navigation above!

Become a sponsor

Support Svelte Society and get your company featured here. Contact us

recipe  posted by  John-Kim Murphy

Simple dual-deployment to Cloudflare (and Vercel/Netlify/etc)

Why? (Motivation)

  • Perhaps you have a project deployed to Vercel, and you want to switch it to Cloudflare
  • Or you have a project deployed to Cloudflare, and you want to switch to Vercel
  • Or you just want to compare the performance of the same app on Cloudflare vs Netlify

Overview

There are two main ways to accomplish Cloudflare dual-deployments:

  1. sv create, then modify for Cloudflare (this recipe focuses on this method)
  2. create-cloudflare, then modify for Vercel/Netlifly

The goal of both methods is to ensure four things:

  • svelte.config.js is configured with @sveltejs/adapter-auto (to select the correct adapter at deployment)
  • The Cloudflare build ENV is set: CF_PAGES=1 (otherwise adapter-auto selects the incorrect adapter)
  • A wranger.toml file (tells Cloudflare's wrangler how to deploy the project)
  • An .assetsignore file (Cloudflare refuses to deploy if generated _worker.js is a static asset)

Steps

  1. npx sv create your SvelteKit project.
  2. Deploy to Vercel. (Works out of the box; adapter-auto is configured by default)
  3. Add wrangler.toml to the root of your project
  4. Deploy to Cloudflare.
    • The build command must be CF_PAGES=1 pnpm build && echo _worker.js > .svelte-kit/cloudflare/.assetsignore
    • Just CF_PAGES=1 pnpm build will work if .assetsignore file with _worker.js is added to static folder.

Notes

  • Don't forget to set your app's environment variables on each platform
    • Vercel: Setting > Environment Variables
    • Cloudflare: Settings > Build > Variables and secrets (buildtime) and/or Settings > Variables and secrets (runtime)

Sample wrangler.toml

name = "<NAME-OF-YOUR-PROJECT>" 
compatibility_date = "2025-10-21" # Use the current date.

main = ".svelte-kit/cloudflare/_worker.js"
compatibility_flags = [ "nodejs_compat" ]

# Bind your static output directory (e.g. the client folder SvelteKit emitted)
[assets]
binding = "ASSETS"
directory = ".svelte-kit/cloudflare"
November 3, 2025

Newsletter

Stay up to date with the Svelte ecosystem.

  • This Week in Svelte — A weekly roundup of the best tutorials, libraries, and community highlights
  • Featured Jobs — Hand-picked Svelte job opportunities from top companies
  • Community News — Announcements, events, and updates from the Svelte team

Newsletter data is processed by Plunk, our email service provider. See our Privacy Policy.