adapter-cloudflare

Cloudflare Workers adapter for Catmint. Transforms Catmint build output into a Cloudflare Workers-compatible bundle deployable with wrangler.

Import

import cloudflare from '@catmint/adapter-cloudflare'

Signature

function cloudflareAdapter(options?: CloudflareAdapterOptions): CatmintAdapter

The default export is the cloudflareAdapter factory function.

Parameters

ParameterTypeRequiredDescription
optionsCloudflareAdapterOptionsNoConfiguration for the Cloudflare Workers deployment.

CloudflareAdapterOptions

PropertyTypeDefaultDescription
routesstring[]['/*']Worker route patterns.
compatibilityDatestringCurrent dateCloudflare Workers compatibility date. Defaults to today's date in YYYY-MM-DD format.

Return Value

Returns a CatmintAdapter object with name: '@catmint/adapter-cloudflare'. When the adapt() method is called during build, it:

  1. Generates worker.js — the Workers entry point
  2. Generates asset-manifest.json — maps URL paths to static files
  3. Generates wrangler.jsonc — Wrangler configuration with the specified compatibility date and routes
  4. Copies client assets and pre-rendered pages to public/
  5. Copies the server bundle into the output directory

Output is written to dist/cloudflare/.

Examples

// catmint.config.ts — defaults
import { defineConfig } from 'catmint/config'
import cloudflare from '@catmint/adapter-cloudflare'

export default defineConfig({
  adapter: cloudflare(),
})
// With custom compatibility date and routes
import { defineConfig } from 'catmint/config'
import cloudflare from '@catmint/adapter-cloudflare'

export default defineConfig({
  adapter: cloudflare({
    compatibilityDate: '2026-01-01',
    routes: ['example.com/*'],
  }),
})

After building, deploy with:

npx wrangler deploy --config dist/cloudflare/wrangler.jsonc

See Also