Skip to content

Phaze + Cloudflare

@madenowhere/phaze-cloudflare is a direct Phaze + Cloudflare Workers deployment — no Astro layer. One Vite plugin handles route discovery, virtual modules, env type-gen, server-entry codegen, and ambient .d.ts emission. The runtime ships half the worker bytes and ~12 % less client JS than the equivalent Astro Cloudflare setup, while keeping the surface — actions, middleware, cookies, endpoints, typed env, streaming SSR, prefetch, view transitions — at near-full parity.

This page walks the surface area side by side with Astro 6.2 + @astrojs/cloudflare 13.3. Each section calls out where the two are at parity, where phaze-cloudflare wins, and where it doesn’t — so the trade-offs are visible up front.

Ahead of Astro:

  • Action surface is 0-byte at runtime (no devalue, defineAction / ActionError compile-stripped, actions.X(input) inlined as a fetch arrow).
  • Per-action middleware + built-in AbortController in useAction.
  • Lazy cookie parsing + lazy env validation — zero cold-start cost when unread.
  • Public env client cost is literally zero — Vite-inlined constants, no virtual module lookup at runtime.
  • No per-island hydration shim — single client entry hydrates the whole page.
  • Named slots are lazy (() => … arrows) — layouts ship without computed.
  • Multi-child JSX wraps as arrays, not Fragment — keeps Fragment symbol out of phaze.
  • Worker bundle is half the size (99 KB vs 194 KB brotli).
  • head() + loader() parallel, first byte goes out as soon as head resolves.

At parity: file-system routing, dynamic params, middleware shape, cookies API, streaming SSR, endpoint method exports, view transitions, prefetch (viewport strategy), head metadata.

Behind: MDX, view-transition element-level persistence, hover/tap prefetch strategies, dev toolbar (intentional). <Image> is at functional parity but uses a different transformation pipeline (CF edge vs Astro’s build-time sharp) — same end-user output, different deploy trade-off. Content Collections ship the same shape — phaze’s newCollection + getCollection mirror Astro’s; no built-in markdown renderer (pipe body through marked / markdown-it / unified if you need HTML).

  • Routing & components — file-system routing and the component model
  • Server-side — request lifecycle, Phaze actions, endpoints, middleware, cookies, typed env
  • Rendering — SSR & streaming, and render + hydrate performance
  • Client-side — client-side router, view transitions, prefetch, head metadata
  • Build & dev — build configuration & adapter layering, type checking, dev experience
  • Gaps & extras — where the surface isn’t at parity, <Image>, content collections, static prerendering