Skip to main content
The @sveltejs/adapter-cloudflare adapter deploys your SvelteKit app to Cloudflare Workers with static assets or Cloudflare Pages.

Installation

Usage

Add the adapter to your svelte.config.js:

Configuration options

From the adapter type definitions:

config

Path to your Wrangler configuration file.

fallback

Controls how 404 errors are handled:
  • 'plaintext' (default): Returns a simple “Not Found” text response
  • 'spa': Generates a SPA fallback page for client-side routing
From the implementation:

routes

Only for Cloudflare Pages. Customizes the automatically-generated _routes.json file that controls routing.
The placeholders <build>, <files>, <prerendered>, and <all> are automatically expanded by the adapter.

platformProxy

Configuration passed to Wrangler’s getPlatformProxy during development:

Wrangler configuration

Create a wrangler.toml file in your project root:

Environment bindings

Access Cloudflare bindings via the platform.env object:
Define bindings in wrangler.toml:

Platform object

The platform object provides access to Cloudflare-specific APIs:
Example usage:

Generated files

The adapter generates several Cloudflare-specific files:
Headers are automatically generated for immutable assets:

Deployment

1

Build your app

2

Deploy to Cloudflare

For Cloudflare Pages, you can also connect your GitHub repository for automatic deployments.

Limitations

Cloudflare Workers have runtime limitations:
  • Maximum script size: 1 MB (after compression)
  • CPU time limit: 10-50ms per request (depends on plan)
  • No access to Node.js APIs