Skip to main content

SvelteKit on Cloudflare Example

This example demonstrates deploying a SvelteKit application to Cloudflare with KV Namespace and R2 Bucket bindings.

Features

  • SvelteKit: Modern Svelte meta-framework
  • KV Namespace: Key-value storage for auth/sessions
  • R2 Bucket: Object storage
  • Environment Bindings: Secrets and configuration
  • Type Safety: Full TypeScript types for platform

Project Setup

Key Features Explained

Multiple Bindings

SvelteKit has access to multiple Cloudflare resources:

Platform Access

Access bindings through the platform object:

KV for Sessions

Use KV Namespace for session storage:

R2 for File Storage

Use R2 Bucket for file uploads:

Advanced Usage

Authentication with KV

Source Code

View the complete source code: examples/cloudflare-sveltekit