ViteHub is still experimental. Expect bugs and breaking changes.

Cloudflare

Configure Cloudflare Provider Output while keeping ViteHub Definitions and Runtime Helpers host-neutral.

Cloudflare is a Provider Selection for packages that can generate Workers, bindings, queues, workflows, schedules, storage, or sandbox output. The Definition and Runtime Helper should stay host-neutral; Cloudflare details belong in Integration Options and Provider Output.

Cloudflare boundaries

ConcernViteHub boundary
Workers and generated bundlesProvider Output written during production-shaped builds.
D1, R2, KV, Queues, Workflows, and Sandbox resourcesPrimitive package configuration plus Provision Steps where available.
CredentialsProvider env vars for provisioning or host runtime secrets through Server Env.
Runtime contextRuntime Host Context passed by the host integration, not app-owned global state.
Agent stateAgent Package state provider configuration when Cloudflare-backed state is selected.

Configure provider-owned primitives

Use the primitive package options to select Cloudflare. The exact option belongs to the package that owns the primitive.

vite.config.ts
import { hubDb } from '@vite-hub/database/vite'
import { hubQueue } from '@vite-hub/queue/vite'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [
    hubDb(),
    hubQueue(),
  ],
  database: {
    driver: 'd1',
    binding: 'DB',
    databaseName: 'app',
  },
  queue: {
    provider: 'cloudflare',
    binding: 'JOBS',
  },
})

Provision missing resources

Preview before applying. Provision writes non-secret ids into .vitehub/provision.json; secrets remain in environment variables or provider env stores.

Terminal
pnpm vitehub provision run --provider cloudflare --dry-run
CLOUDFLARE_ACCOUNT_ID=... CLOUDFLARE_API_TOKEN=... pnpm vitehub provision run --provider cloudflare

Inspect output

Cloudflare output can include worker bundles, wrangler.json, D1 bindings, queue consumers, cron triggers, and package-specific runtime imports. Inspect output after a production-shaped build.

Terminal
pnpm build
find dist -maxdepth 4 -type f | sort

Production notes

Cloudflare local development and deployed Workers do not always expose the same runtime behavior. Use Provider Output Contracts and Local Provider Runs for pull request checks, then keep Live Smoke thin against real Cloudflare deployments.

Cloudflare Provider Output can require real Worker bindings such as D1, R2, KV, Queues, Durable Objects, Cloudflare Artifacts, or Agent state. Verify generated bindings before deploy, then smoke test the deployed Worker when runtime bindings matter.

Agent Definitions can run on Cloudflare through the Agent Package's Cloudflare handler, or through generated host output where the Agent integration owns that route. Keep model keys, Durable Object state bindings, and other Runtime Env in Worker bindings.

Next steps

Copyright © 2026