Skip to main content
Deploy SvelteKit applications to Cloudflare Workers using the Cloudflare adapter.

Installation

Install the required dependencies:

Configuration

Configuration Options

Properties

  • bindings: Cloudflare bindings (KV, R2, D1, etc.)
  • entrypoint: Worker entrypoint path
    • Default: .svelte-kit/cloudflare/_worker.js
  • assets: Static assets directory
    • Default: .svelte-kit/cloudflare
  • compatibilityDate: Cloudflare compatibility date
    • Minimum: 2024-09-23 (required for nodejs_compat)
  • compatibilityFlags: Additional compatibility flags
    • Default: ["nodejs_compat"]

Accessing Bindings

Access Cloudflare bindings in your SvelteKit application:

Server Load Functions

Server Actions

API Routes

Local Development

SvelteKit provides excellent local development support:
  • Emulated Cloudflare platform.env bindings
  • Hot module replacement
  • Fast refresh
Start the dev server:
The platform object is available in all server-side code during development.

Node.js Compatibility

The SvelteKit resource automatically enables nodejs_compat compatibility flag, which provides:
  • Node.js built-in modules (fs, path, crypto, etc.)
  • Support for npm packages that depend on Node.js APIs
  • Full SvelteKit feature compatibility

Minimum Compatibility Date

For nodejs_compat support, the compatibility date must be >= 2024-09-23:

TypeScript Configuration

Configure TypeScript for Cloudflare platform types:

Deployment Best Practices

  • Keep .svelte-kit directory in .gitignore
  • Use environment variables for secrets via alchemy.secret.env.X
  • Test bindings locally using SvelteKit’s platform proxy
  • Configure proper TypeScript types for platform bindings