Skip to content

Cloudflare

Copy page

Deploy Nizhal on Cloudflare Workers with Durable Objects as the realtime hub.

import { createNizhalWorkerFetchHandler } from "@nizhal/server/adapters/cloudflare";
import { cloudflareRealtime } from "@nizhal/server/adapters/cloudflare";
export default createNizhalWorkerFetchHandler({
db: env.HYPERDRIVE.connectionString,
schema,
mutators,
syncRules,
auth,
realtime: cloudflareRealtime({ env }),
});

Export NizhalBucket (PartyServer Server subclass) in wrangler.toml as a Durable Object binding.

import { createCloudflareSubscribeSource } from "@nizhal/db-collection";
// or createNizhalNitroClient on mobile

PartySocket reconnect semantics match the in-process WS server.

  • Durable Object outbound connections idle ~15 minutes — fine for ping-and-repull; clients reconnect; cursor pull catches up
  • Storage remains Postgres (often via Hyperdrive to Neon/RDS) — DO is realtime only, not the system of record

packages/server/examples/run-cf-e2e.sh and cf-e2e-smoke.ts exercise the Workers path.