Skip to content

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.

The Cloudflare adapter is configured in svelte.config.js:

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.toml
name = "honeycomb"
compatibility_date = "2025-03-01"
pages_build_output_dir = ".svelte-kit/cloudflare"
compatibility_flags = ["nodejs_compat"]
FieldValuePurpose
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

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 operations
  • node: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.

Terminal window
npm run build

This runs vite build, which:

  1. Compiles all Svelte components and TypeScript
  2. Bundles client-side assets with code-splitting
  3. Generates the server-side Worker via the Cloudflare adapter
  4. Outputs everything to .svelte-kit/cloudflare/
Terminal window
npm run preview

Serves 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:

Terminal window
npx wrangler pages dev .svelte-kit/cloudflare
Terminal window
npm run check

Runs svelte-kit sync (generates type declarations) followed by svelte-check against the TypeScript config.

Connect the GitHub repository to Cloudflare Pages in the dashboard:

  1. Go to Workers & Pages in the Cloudflare dashboard
  2. Create a new Pages project and connect the repository
  3. Set the build configuration:
    • Build command: npm run build
    • Build output directory: .svelte-kit/cloudflare
    • Root directory: / (or the monorepo subdirectory if applicable)

Cloudflare will automatically build and deploy on every push to the production branch, with preview deployments for pull requests.

Alternatively, deploy a local build directly:

Terminal window
npm run build
npx wrangler pages deploy .svelte-kit/cloudflare --project-name honeycomb

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.

VariableVisibilityDescription
PUBLIC_SUPABASE_URLPublicSupabase project URL
PUBLIC_SUPABASE_ANON_KEYPublicSupabase anonymous/public key
SUPABASE_SERVICE_ROLE_KEYPrivateSupabase service role key (full access)
STRIPE_SECRET_KEYPrivateStripe API secret key
STRIPE_WEBHOOK_SECRETPrivateStripe webhook signing secret
OPENAI_API_KEYPrivateOpenAI API key for AI features

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.

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.

Supabase TypeScript types are generated from the live schema and committed to the repository:

Terminal window
npm run db:types

This runs:

Terminal window
npx supabase gen types typescript --project-id "$PROJECT_REF" > src/lib/types/database.ts

Set the PROJECT_REF environment variable to your Supabase project reference ID before running this command. Regenerate types whenever the database schema changes.