Skip to content

React 19 Server Components · standard web APIs

Request in.Response out.

Juice is a React framework where your whole server is a single fetch handler. It has no special request object, doesn't tie you to one host, and has two dependencies. Everything between the Request and the Response is code you can read.

  • Cloudflare Workers
  • Bun
  • Deno
  • Node.js
server.ts
import { createRouter } from '@cmj/juice/runtime';
import manifest from './flight-manifest.json';

export default { fetch: createRouter(manifest) };
That's the whole server. Not a simplified version.

How it works

One request, start to finish.

The compiler writes one inspectable manifest. The runtime reads it and runs each request through the same five steps on every host. Each step is either a file you wrote or a web standard.

  1. 01Request

    The standard web Request object, the same one fetch() uses.

  2. 02middleware.ts

    Auth, headers, redirects. Return early or call next().

  3. 03page.tsx

    An async component. Await your data right here.

  4. 04React 19 stream

    HTML on first load, just the changed segment on navigation.

  5. 05Response

    A standard Response. Cache it, inspect it, return it.

The whole model

Three files make an app.

Reading data, writing data and guarding routes each take one small file of familiar code.

01Read

Your component is the data layer.

Server components are async functions. Import your database and await it during render. No loaders, no getServerSideProps, no API route in between.

app/routes/home.tsx
import { db } from '../lib/db';
import { addTodo } from './actions';

export default async function Home() {
  const todos = await db.todos.list();

  return (
    <>
      <ul>{todos.map(t => <li key={t.id}>{t.title}</li>)}</ul>
      <form action={addTodo}>
        <input name="title" />
      </form>
    </>
  );
}

02Write

Mutations are forms.

React 19 server actions receive the parsed FormData, are CSRF-checked by the runtime, and keep working with JavaScript turned off.

app/routes/actions.ts
'use server';
import { redirect } from '@cmj/juice/runtime';
import { db } from '../lib/db';

export async function addTodo(formData: FormData) {
  await db.todos.add(String(formData.get('title')));
  redirect('/', 303);
}

03Guard

Middleware is plain HTTP.

Drop a middleware.ts in any directory. It gets the Request and calls next() to continue, or returns a Response to stop. Nested directories run in order, outermost first.

app/routes/admin/middleware.ts
export default async function middleware(
  req: Request,
  next: () => Promise<Response>,
) {
  if (!req.headers.get('cookie')?.includes('session=')) {
    return new Response('Unauthorized', { status: 401 });
  }
  return next();
}

Framework facts

Small, and measured.

Each number comes with how it was measured. The benchmark scripts are in the repo, so you can run them yourself.

2
Runtime dependencies

react-server-dom-webpack and urlpattern-polyfill. React itself is a peer dependency.

25KB
Gzipped runtime

Routing, rendering, actions, middleware, CSRF and caching, gzipped.

43ms
Cold start, p50

From process start to first response, including importing the runtime and creating the router.

33.6K
Requests per second

About half of raw Bun's throughput, including route matching, request context and CSRF checks. Measured with 50 concurrent connections over 10 seconds.

Measured with Bun 1.3 on macOS (x64). Reproduce with bun bench/cold-start.ts 20, read the methodology, or see the live benchmarks.

Coming from Next.js

Same React, fewer layers above HTTP.

Your components, hooks and server actions move over as they are. What changes is everything around them, and you can read all of it.

Read the migration guide →
Next.jsJuice
Request objectNextRequest / NextResponse helpersStandard Request / Response
MiddlewareOne root file for the whole appA middleware.ts per directory, nested in order
Data cachingFramework caching layers and directivesExplicit cache(fn) that you call yourself
RuntimeNode-first, with an edge subsetBuilt on WinterCG APIs: the same handler runs on Workers, Bun, Deno and Node
StreamingOn by default through SuspenseChosen per route: buffered, shell or full
Build outputA framework server with deployment adaptersOne readable flight-manifest.json

Developer experience

Errors that tell you how to fix them.

Every Juice message says what happened, why, and the exact command that fixes it. Docs for coding agents ship as part of the framework.

vite dev
[juice] ⚠ Route "post.tsx" maps to "/blog/post" (static).
Your component references params.slug which suggests a dynamic route.
Did you mean: [slug].tsx → /blog/:slug
Rename the file to enable dynamic params:
mv app/routes/blog/post.tsx app/routes/blog/[slug].tsx

Before you choose

What Juice doesn't do yet.

If any of these is a dealbreaker, it's better to know now than after you've migrated.

No partial rendering yet

SPA navigations replace the full React tree. Preserving layouts across navigations is on the roadmap.

A young ecosystem

There are guides for auth, Stripe, Prisma, Drizzle, Redis, Resend and more, but no plugin marketplace.

HTTP knowledge helps

Juice is easiest for teams that already know Request, Response, headers, status codes and the tradeoffs between runtimes.

Squeeze out your first app.

Scaffold a project, choose where it runs, and have a server component rendering in under a minute.

npx @cmj/juice create my-app --target cloudflare