Deployment
Honeycomb deploys to Cloudflare Pages using the official SvelteKit adapter. The build produces a Pages-compatible output that runs on the Cloudflare Workers runtime.
Adapter setup
Section titled “Adapter setup”The Cloudflare adapter is configured in svelte.config.js:
import adapter from '@sveltejs/adapter-cloudflare';
/** @type {import('@sveltejs/kit').Config} */const config = { kit: { adapter: adapter() }};
export default config;The adapter takes no additional options — the defaults work for Pages deployments. It compiles SvelteKit’s server-side code into a Cloudflare Workers-compatible format and places the output in .svelte-kit/cloudflare/.
Package: @sveltejs/adapter-cloudflare (v7.x)
Wrangler configuration
Section titled “Wrangler configuration”name = "honeycomb"compatibility_date = "2025-03-01"pages_build_output_dir = ".svelte-kit/cloudflare"compatibility_flags = ["nodejs_compat"]Key fields
Section titled “Key fields”| Field | Value | Purpose |
|---|---|---|
name | "honeycomb" | Project name in Cloudflare dashboard |
compatibility_date | "2025-03-01" | Pins the Workers runtime to this date’s behavior |
pages_build_output_dir | ".svelte-kit/cloudflare" | Output directory the adapter writes to |
compatibility_flags | ["nodejs_compat"] | Enables Node.js built-in modules |
nodejs_compat flag
Section titled “nodejs_compat flag”The nodejs_compat compatibility flag enables Node.js built-in modules on the Workers runtime. Honeycomb requires this for:
node:crypto— used by Supabase Auth and Stripe SDK for cryptographic operationsnode:async_hooks— used internally by some dependencies
Without this flag, any import of node:* modules will fail at runtime with a “module not found” error.
Build process
Section titled “Build process”Local build
Section titled “Local build”npm run buildThis runs vite build, which:
- Compiles all Svelte components and TypeScript
- Bundles client-side assets with code-splitting
- Generates the server-side Worker via the Cloudflare adapter
- Outputs everything to
.svelte-kit/cloudflare/
Preview locally
Section titled “Preview locally”npm run previewServes the built output using Vite’s preview server. Note that this does not use the Cloudflare Workers runtime — for a production-accurate preview, use wrangler pages dev:
npx wrangler pages dev .svelte-kit/cloudflareType checking
Section titled “Type checking”npm run checkRuns svelte-kit sync (generates type declarations) followed by svelte-check against the TypeScript config.
Cloudflare Pages deployment
Section titled “Cloudflare Pages deployment”Git integration (recommended)
Section titled “Git integration (recommended)”Connect the GitHub repository to Cloudflare Pages in the dashboard:
- Go to Workers & Pages in the Cloudflare dashboard
- Create a new Pages project and connect the repository
- Set the build configuration:
- Build command:
npm run build - Build output directory:
.svelte-kit/cloudflare - Root directory:
/(or the monorepo subdirectory if applicable)
- Build command:
Cloudflare will automatically build and deploy on every push to the production branch, with preview deployments for pull requests.
Direct upload
Section titled “Direct upload”Alternatively, deploy a local build directly:
npm run buildnpx wrangler pages deploy .svelte-kit/cloudflare --project-name honeycombEnvironment variables
Section titled “Environment variables”Environment variables are managed in the Cloudflare Pages dashboard under Settings > Environment variables. SvelteKit accesses them via two import paths:
import { STRIPE_SECRET_KEY } from "$env/static/private";Only available in +server.ts, +page.server.ts, +layout.server.ts, and hooks.server.ts. Never sent to the browser.
import { PUBLIC_SUPABASE_URL } from "$env/static/public";Prefixed with PUBLIC_. Inlined into the client bundle at build time.
Required variables
Section titled “Required variables”| Variable | Visibility | Description |
|---|---|---|
PUBLIC_SUPABASE_URL | Public | Supabase project URL |
PUBLIC_SUPABASE_ANON_KEY | Public | Supabase anonymous/public key |
SUPABASE_SERVICE_ROLE_KEY | Private | Supabase service role key (full access) |
STRIPE_SECRET_KEY | Private | Stripe API secret key |
STRIPE_WEBHOOK_SECRET | Private | Stripe webhook signing secret |
OPENAI_API_KEY | Private | OpenAI API key for AI features |
Environment-specific values
Section titled “Environment-specific values”Cloudflare Pages supports separate variable sets for Production and Preview environments. Use different Supabase projects or Stripe test keys for preview deployments to avoid polluting production data.
Compatibility date
Section titled “Compatibility date”The compatibility_date in wrangler.toml pins the Workers runtime behavior. Cloudflare rolls out breaking changes behind date-gated flags. Setting 2025-03-01 means the runtime behaves as it did on that date.
To adopt newer runtime features, bump the date forward and test thoroughly. Check the Cloudflare compatibility dates documentation for a changelog of what each date enables.
Database types
Section titled “Database types”Supabase TypeScript types are generated from the live schema and committed to the repository:
npm run db:typesThis runs:
npx supabase gen types typescript --project-id "$PROJECT_REF" > src/lib/types/database.tsSet the PROJECT_REF environment variable to your Supabase project reference ID before running this command. Regenerate types whenever the database schema changes.