Skip to content

docs: update Cloudflare deployment guide #15056

@hyunbinseo

Description

@hyunbinseo

Describe the bug

Recommend nodejs_compat flag instead of putting it in the troubleshooting section. Related:

 Svelte error: async_local_storage_unavailable
      The node API `AsyncLocalStorage` is not available, but is required to use async server rendering.
      https://svelte.dev/e/async_local_storage_unavailable

Guide users to set the compatibility_date to the current date. Reference

When you start your project, you should always set compatibility_date to the current date.

{
	"name": "<any-name-you-want>",
	"main": ".svelte-kit/cloudflare/_worker.js",
	"compatibility_date": "2025-01-01", // almost an year has passed
	"assets": {
		"binding": "ASSETS",
		"directory": ".svelte-kit/cloudflare",
	}
}

Add a wrangler.jsonc example for the Cloudflare Pages section.

This helps adding the nodejs_compat flag A LOT easier.

- assets # reserved for Workers only
+ pages_build_output_dir # required

The name 'ASSETS' is reserved in Pages projects. Please use a different name for your Assets binding.

A wrangler.toml file was found but it does not appear to be valid. Did you mean to use wrangler.toml to configure Pages? If so, then make sure the file is valid and contains the pages_build_output_dir property. Skipping file and continuing.

{
	"name": "svelte-kit-cloudflare",
	"pages_build_output_dir": ".svelte-kit/cloudflare", // required
	"compatibility_flags": ["nodejs_compat"], // easier to add
	"compatibility_date": "2025-12-12" // easier to add
}

Remove trailing comma from the wrangler.jsonc example

It does work in Workers but causes parse error in Pages. Related:

{
	"name": "<any-name-you-want>",
	"main": ".svelte-kit/cloudflare/_worker.js",
	"compatibility_date": "2025-01-01",
	"assets": {
		"binding": "ASSETS",
		"directory": ".svelte-kit/cloudflare", // causes parse error in the Pages build system
	}
}

Add the $schema field in wrangler.jsonc. Requires wrangler installation, but it provides type safety.

{
	"$schema": "./node_modules/wrangler/config-schema.json", // Added

Reproduction

https://github.com/hyunbinseo/svelte-kit-cloudflare

Logs

System Info

System:
  OS: Windows 11 10.0.26200
  CPU: (8) x64 Intel(R) Core(TM) Ultra 7 258V
  Memory: 9.67 GB / 31.48 GB
Binaries:
  Node: 24.12.0 - C:\Users\hyunb\AppData\Local\fnm_multishells\11728_1765560385450\node.EXE
  npm: 11.6.2 - C:\Users\hyunb\AppData\Local\fnm_multishells\11728_1765560385450\npm.CMD
  pnpm: 10.25.0 - C:\Users\hyunb\AppData\Local\fnm_multishells\11728_1765560385450\pnpm.CMD
  Deno: 2.4.0 - C:\Users\hyunb\.deno\bin\deno.EXE
Browsers:
  Chrome: 143.0.7499.109
  Edge: Chromium (140.0.3485.54)
  Firefox: 146.0 - C:\Program Files\Mozilla Firefox\firefox.exe
npmPackages:
  @sveltejs/adapter-cloudflare: ^7.2.4 => 7.2.4
  @sveltejs/kit: ^2.49.2 => 2.49.2
  @sveltejs/vite-plugin-svelte: ^6.2.1 => 6.2.1
  svelte: ^5.45.10 => 5.45.10
  vite: ^7.2.7 => 7.2.7

Severity

annoyance

Additional Information

It would be nice if the sv CLI added wrangler.jsonc during scaffolding.

Choosing the cloudflare adapter basically means CF Workers or Pages deployment.

◇  What would you like to add to your project? (use arrow keys / space bar)
│  sveltekit-adapter
│
◇  Which SvelteKit adapter would you like to use?
│  cloudflare

Could this be achieved? @jycouet

  • Install @sveltejs/adapter-cloudflare and wrangler as well
  • Create a wrangler.jsonc file with the $schema field set
  • Include nodejs_compat flag and set the date to the date of scaffolding

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions