Cloudflare
⚠️ Beta Stage: Photon is currently in beta. APIs may change before stable release.
Deploy your Photon application to Cloudflare Workers and Pages.
Prerequisites
npm install -g wrangler
wrangler login
Installation
Install the Cloudflare adapter:
npm install @photonjs/runtime @photonjs/cloudflare
Configuration
Vite Configuration
Add the Cloudflare adapter to your Vite config:
// vite.config.ts
import { photon } from '@photonjs/runtime/vite'
import { cloudflare } from '@photonjs/cloudflare/vite'
export default {
plugins: [
photon(),
cloudflare()
]
}
Wrangler Configuration
Create a wrangler.toml
file:
name = "my-photon-app"
main = "photon:cloudflare:photon:server-entry"
compatibility_date = "2025-08-28"
[build]
command = "npm run build"
[[kv_namespaces]]
binding = "MY_KV"
id = "your-kv-namespace-id"
[vars]
ENVIRONMENT = "production"
Deployment
Preview
Test build output locally with Wrangler:
npm run build
wrangler dev
Production
Deploy to Cloudflare:
npm run build
wrangler deploy