React Server Components 20 🧬 Choosing a Runtime — Next.js, Waku, or custom bundler setups
The "use server" directive does not execute anywhere on its own. It is a marker that a runtime must interpret. The bundler must recognize the directive, generate a client-side reference, create a server endpoint, and wire the serialization between them. The React documentation states this explicitly: the underlying APIs used to implement Server Functions in a bundler or framework “do not follow semver and may break between minors in React 19.x” . Choosing a runtime is choosing which implementation of those unstable APIs you are willing to depend on, and what you are willing to give up in exchange for stability.
The three options occupy distinct positions on a spectrum. Next.js is the integrated platform: it owns routing, caching, build pipeline, and deployment, and it implements Server Functions as one part of that whole. Waku is the minimal framework: it implements the RSC primitives with a small surface area, no implicit caching, and direct execution semantics, leaving most decisions to the developer . A custom bundler setup is the bare-metal option: libraries like @mfng/webpack-rsc or forket provide the loaders and plugins to build RSC bundles, but the developer owns the HTTP server, the routing, the SSR pipeline, and every integration point that a framework would have provided .
Key point: The choice is not about which runtime is “best.” It is about which set of decisions you want the framework to make for you. Next.js makes the most decisions; Waku makes the fewest while still being a framework; a custom bundler makes none.
Why the runtime choice matters for "use server"
The implementation dependency. The "use server" directive is standardized at the React level, but its implementation is not. React provides the runtime primitives—the reference format, the serialization protocol, the transition integration—but the bundler must produce the client-side reference and the server endpoint. When React 19.x changes those internal APIs between minor versions, the bundler must adapt. Next.js and Waku track these changes as part of their release cycles. A custom setup pins a React version and absorbs the upgrade cost manually .
The caching model. The directive itself says nothing about caching. But the runtime determines whether a Server Function’s result is cached, whether the page that rendered the form is cached, and whether revalidatePath or revalidateTag exist as concepts. Next.js has an explicit caching model that the developer must reason about . Waku has no implicit cache; data fetching is direct, and invalidation is not a framework concern . A custom setup has whatever cache the developer builds.
The deployment surface. A Server Function is an HTTP endpoint. The runtime determines where that endpoint lives: inside a Next.js server, inside a Waku server, or inside an Express app with a custom /@forket route . The deployment target—Vercel, a Node.js server, an edge runtime—constrains which runtimes are viable. Next.js is optimized for Vercel but deployable elsewhere. Waku is a Node.js server. A custom setup is whatever the developer builds.
The trade-off. Next.js gives you a working Server Function in three lines: write the function, add the directive, pass it to a form. The cost is the framework’s opinions about caching, routing, and the build pipeline. Waku gives you the same three lines with fewer opinions, but you build the missing pieces—metadata, image optimization, API routes—yourself or with other libraries . A custom bundler gives you the primitives and nothing else. The developer who chooses it is choosing to own the integration.
a. Next.js: the integrated platform
Next.js implements "use server" as part of a complete application platform. The directive works out of the box: the App Router recognizes it, the build pipeline generates the endpoint, the client bundle contains the reference, and the form action integration is wired through useActionState, useFormStatus, and useOptimistic.
// app/actions.ts — Next.js implementation
'use server';
import { db } from '@/lib/db';
import { auth } from '@/lib/auth';
import { revalidatePath } from 'next/cache';
export async function createComment(formData: FormData) {
const session = await auth();
if (!session?.user) throw new Error('Unauthorized');
const body = formData.get('body') as string;
if (!body) return { error: 'Required' };
await db.comment.create({ data: { body, authorId: session.user.id } });
// revalidatePath is a Next.js-specific API.
// It has no equivalent in Waku or a custom setup.
revalidatePath('/posts');
return { error: null };
}
The revalidatePath call is the visible marker of the integrated model. Next.js owns the cache, so it owns the invalidation API. The developer does not choose how the cache works; the framework provides the mechanism and the developer uses it. The Waku comparison page states the difference plainly: Next.js optimizes for an integrated platform with “a caching and revalidation model that controls rendering from whole routes down to individual functions,” while Waku optimizes for “a small framework-owned surface with direct execution semantics, no implicit cache to reason about” .
The cost of this integration is the learning curve of the caching model itself. The developer must understand when a page is static, when it is dynamic, when a fetch is cached, and when revalidatePath is the right tool versus revalidateTag. The platform makes the decision for you, but it does not make the decision invisible.
b. Waku: the minimal RSC framework
Waku is described as “a minimal React framework” designed for small to medium-sized React projects with Server Components, created by the maintainers of Zustand and Jotai . It implements "use server" with the same directive syntax as React specifies, but without the surrounding platform. The server action support in Waku v0.21 covers inline actions in Server Components, actions imported from separate files, and form action invocation .
// src/actions/send-message.ts — Waku implementation
'use server';
import db from 'some-db';
export async function sendMessage(formData: FormData) {
// The directive works the same way.
// The difference is what surrounds it.
const message = formData.get('message') as string;
// There is no revalidatePath. There is no implicit cache.
// The function runs, the database is mutated, and the page
// re-renders according to whatever the component tree does.
await db.messages.create({ message });
}
The absence of revalidatePath is the defining characteristic. Waku does not have a built-in caching layer to invalidate. The developer fetches data in async Server Components, and the component re-renders when the action completes because the action’s execution is part of a transition. There is no cache to reason about because there is no cache .
Waku also lacks built-in API routes, metadata handling, and image optimization. These are not omissions; they are the design. The framework owns the RSC primitives and the file-based routing, and leaves the rest to the developer or to ecosystem libraries . For a project that needs a comment form and a database write, this is sufficient. For a project that needs SEO metadata, image optimization, and analytics, the developer assembles those pieces separately.
The choice between Next.js and Waku is the choice between an integrated platform and a minimal framework. The Waku comparison documentation frames it directly: “If you want an integrated platform, Next.js is a strong choice; if you prefer to keep more of those decisions in your own hands, Waku may be the better fit” .
c. Custom bundler setups: owning the integration
A custom bundler setup uses libraries that provide the RSC bundling primitives without the framework. @mfng/webpack-rsc provides Webpack loaders and plugins for building RSC bundles for browser and server, with server-side rendering . forket is a library that splits code into client and server versions and requires the developer to instrument their HTTP server . Neither provides routing, caching, or a deployment model.
// Express server with forket integration — custom setup
import express from 'express';
import Forket from 'forket';
const app = express();
Forket().then((forket) => {
// The developer wires the Server Function endpoint manually.
// The path is configurable; there is no framework convention.
app.use('/@forket', forket.forketServerActions());
// The developer serves the app manually.
app.get('/', forket.serveApp({
factory: (req) => <App request={req} />,
}));
});
app.listen(8087);
The "use server" directive still works in this setup. The bundler recognizes it, generates the reference, and the server action endpoint handles the invocation. What the developer provides is everything else: the HTTP server, the route definitions, the SSR pipeline, the client bundle configuration, and the deployment target. The forket documentation is explicit about the mental model: it performs static analysis before the usual pipeline, produces client and server versions, and requires the developer to “hook your current building tools to process the files” .
The @mfng/webpack-rsc library carries a similar warning: “There are many moving parts involved in creating an RSC app that also handles SSR, without using a framework like Next.js. This library only provides the necessary parts for bundling the app” . The library is experimental. The developer who chooses this path is choosing to own the integration cost in exchange for complete control.
Complete Example Session
// ============================================
// PART 1: THE SAME SERVER FUNCTION, THREE RUNTIMES
// ============================================
// The function body is identical in all three runtimes.
// The difference is what the runtime provides around it.
async function createPost(formData: FormData) {
'use server';
const session = await getSession();
if (!session) throw new Error('Unauthorized');
const title = formData.get('title') as string;
await db.post.create({ data: { title, authorId: session.user.id } });
}
// ============================================
// PART 2: NEXT.JS — INTEGRATED CACHING
// ============================================
// app/actions.ts
'use server';
import { revalidatePath } from 'next/cache';
export async function createPostNext(formData: FormData) {
// ... auth and mutation ...
await db.post.create({ data: { title, authorId: session.user.id } });
// Next.js provides the invalidation API.
// The cache is the framework's, and so is the mechanism to clear it.
revalidatePath('/posts');
}
// ============================================
// PART 3: WAKU — DIRECT EXECUTION, NO CACHE
// ============================================
// src/actions/create-post.ts
'use server';
import db from 'some-db';
export async function createPostWaku(formData: FormData) {
// ... auth and mutation ...
await db.post.create({ data: { title, authorId: session.user.id } });
// No revalidatePath. No cache to invalidate.
// The action runs, the transition settles, the component
// re-renders with fresh data from the Server Component.
}
// ============================================
// PART 4: WAKU — FORM INVOCATION
// ============================================
// src/pages/posts.tsx — Waku Server Component
import { createPostWaku } from '../actions/create-post';
export default function PostsPage() {
return (
<form action={createPostWaku}>
<input name="title" />
<button type="submit">Create</button>
</form>
);
}
// Waku supports the same form action integration.
// The directive, the FormData argument, and the action prop
// behave identically to React's specification.
// ============================================
// PART 5: CUSTOM BUNDLER — FORKET SERVER SETUP
// ============================================
// server.ts — Express with forket
import express from 'express';
import Forket from 'forket';
import { App } from './App';
const app = express();
Forket().then((forket) => {
// The Server Function endpoint is mounted at a configurable path.
// The developer owns the path, the middleware, and the server.
app.use('/@forket', forket.forketServerActions());
app.get('/', forket.serveApp({
factory: (req) => <App request={req} />,
}));
});
app.listen(3000);
// ============================================
// PART 6: CUSTOM BUNDLER — WEBPACK RSC CONFIGURATION
// ============================================
// webpack.config.js — @mfng/webpack-rsc
import {
WebpackRscClientPlugin,
WebpackRscServerPlugin,
createWebpackRscClientLoader,
createWebpackRscServerLoader,
} from '@mfng/webpack-rsc';
const clientReferencesMap = new Map();
const serverReferencesMap = new Map();
const serverConfig = {
// ... server bundle configuration ...
plugins: [
new WebpackRscServerPlugin({ clientReferencesMap, serverReferencesMap }),
],
};
const clientConfig = {
// ... client bundle configuration ...
plugins: [
new WebpackRscClientPlugin({ clientReferencesMap }),
],
};
export default [serverConfig, clientConfig];
// The library provides the loaders and plugins.
// The developer provides the entry points, the output paths,
// the HTML shell, and the server that serves them.
// ============================================
// PART 7: THE DECISION AXIS
// ============================================
// The question is not "which is best."
// The question is "which decisions do I want to own?"
// Next.js:
// - Routing: framework owns
// - Caching: framework owns, explicit API to invalidate
// - Build: framework owns (Turbopack)
// - Deployment: framework-optimized (Vercel first)
// - Server Functions: wired, integrated with cache
// Waku:
// - Routing: framework owns (file-based)
// - Caching: developer owns (no built-in cache)
// - Build: framework owns (Vite)
// - Deployment: developer owns (Node.js server)
// - Server Functions: wired, direct execution
// Custom bundler:
// - Routing: developer owns
// - Caching: developer owns
// - Build: developer owns (Webpack/Vite config)
// - Deployment: developer owns (Express/Node server)
// - Server Functions: primitives provided, wiring by developer
// ============================================
// PART 8: WAKU'S EXPLICIT STATIC/DYNAMIC SPLIT
// ============================================
// Waku requires the developer to declare render mode per page.
// Next.js infers it from the code (cookies(), headers(), noStore()).
//
// src/pages/index.tsx — Waku
export default function HomePage() {
return <div>Static content</div>;
}
// src/entries.tsx — Waku page registration
import { createPages } from 'waku';
import HomePage from './pages/index';
export default createPages(async ({ createPage }) => {
createPage({
path: '/',
component: HomePage,
render: 'static', // Explicit. Next.js would infer this.
});
});
// The trade-off is verbosity for clarity.
// The developer cannot accidentally ship a dynamic page as static.
// ============================================
// PART 9: WHAT WAKU DOES NOT PROVIDE
// ============================================
// No next/image equivalent. Use a CDN or build-time optimization.
// No next/font equivalent. Load fonts manually.
// No metadata API. Set <head> tags in the root layout.
// No API routes. Use Server Components or a separate server.
// No revalidatePath. No implicit cache to invalidate.
// These are not bugs. They are the framework's scope.
// ============================================
// PART 10: THE VERDICT FOR EACH USE CASE
// ============================================
// Choose Next.js when:
// - You need the integrated platform (caching, routing, images, metadata)
// - You are deploying to Vercel or a similar platform
// - You want the Server Function to be one part of a complete system
// - You are willing to learn the caching model
// Choose Waku when:
// - You want RSC without the Next.js surface area
// - You are comfortable assembling metadata, images, and analytics yourself
// - You prefer direct execution over implicit caching
// - You want the smallest viable RSC framework
// Choose a custom bundler when:
// - You have an existing server and routing layer
// - You need complete control over the build and deployment
// - You are willing to own the integration cost
// - You are experimenting or building a framework yourself
The ten parts covered the same Server Function across three runtimes, the caching difference, the form integration parity, the custom server setup, the Webpack configuration, and the decision criteria. The through-line is that the directive is portable but the surrounding platform is not.
Quick Reference
Runtime comparison
| Aspect | Next.js | Waku | Custom bundler |
|---|---|---|---|
"use server" support | Yes | Yes | Yes (via libraries) |
| Form action integration | Yes | Yes | Yes (via libraries) |
| Built-in caching | Yes (explicit API) | No | No |
revalidatePath | Yes | No | No |
| File-based routing | Yes | Yes | No |
| Image optimization | Yes | No | No |
| Metadata API | Yes | No | No |
| API routes | Yes | No (v0.21) | No |
| Deployment | Vercel-optimized | Node.js | Developer-owned |
When to choose each
| Choose | When |
|---|---|
| Next.js | You want an integrated platform and accept its caching model |
| Waku | You want RSC primitives with minimal framework surface |
| Custom bundler | You have existing infrastructure and need full control |
Stability warnings
| Source | Warning |
|---|---|
| React docs | Server Function implementation APIs “do not follow semver” in 19.x |
@mfng/webpack-rsc | “Experimental” |
forket | Requires manual HTTP server instrumentation |
Best Practices
✅ Do This:
// Use Next.js when you need the integrated platform
revalidatePath('/posts'); // ✅ (Next.js)
// Use Waku when you want RSC without the cache layer
// No revalidatePath; direct execution // ✅ (Waku)
// Pin React version in custom setups
"react": "19.2.0" // ✅ (custom)
// Read the runtime's comparison docs before choosing
// Each framework documents its trade-offs explicitly // ✅
❌ Don’t Do This:
// Assume "use server" behaves identically across runtimes
// The directive is the same; the surrounding platform is not. // ❌
// Use Next.js-specific APIs in Waku
import { revalidatePath } from 'next/cache'; // ❌ (Waku)
// Deploy a custom bundler setup without owning the server
// The library provides primitives, not a deployment model. // ❌
Common Pitfalls
| Pitfall | Why It Happens | Fix |
|---|---|---|
revalidatePath import fails in Waku | Next.js-specific API | Waku has no cache; remove the call |
| Form action works but data is stale | Waku has no implicit cache | Re-fetch in the Server Component after the action |
| Custom setup endpoints 404 | Server not instrumented | Mount the library’s action endpoint |
| React minor upgrade breaks custom setup | Implementation APIs not semver | Pin React version; upgrade deliberately |
Real-World Examples
1. Next.js revalidation
revalidatePath('/posts'); // Framework owns the cache
2. Waku direct mutation
await db.post.create(...); // No revalidation needed
3. Waku form action
<form action={createPostWaku}>...</form>
4. Forket server mount
app.use('/@forket', forket.forketServerActions());
5. Webpack RSC plugin
new WebpackRscServerPlugin({ clientReferencesMap, serverReferencesMap })
6. Waku explicit render mode
createPage({ path: '/', component: Home, render: 'static' })
7. Next.js metadata
export const metadata = { title: 'Page' };
8. Waku root layout head tags
// No metadata API; set tags manually in the layout
9. Custom deployment
app.listen(8087); // Developer owns the server
10. Pin React in custom setup
{ "react": "19.2.0" }
Visual
The Runtime Spectrum
┌──────────────────────────────────────────────────────────────┐
│ FROM INTEGRATED TO BARE-METAL │
│ │
│ Next.js Waku Custom │
│ ┌─────────────────┐ ┌─────────────┐ ┌─────────┐ │
│ │ Routing │ │ Routing │ │ Routing │ │
│ │ Caching │ │ │ │ │ │
│ │ Images │ │ │ │ │ │
│ │ Metadata │ │ │ │ │ │
│ │ API routes │ │ │ │ │ │
│ │ Server Fns │ │ Server Fns │ │ Server │ │
│ └─────────────────┘ └─────────────┘ │ Fns │ │
│ │ (libs) │ │
│ Most decisions made Fewer decisions └─────────┘ │
│ by the framework made by the All decisions│
│ framework by developer│
│ │
│ The developer moves from consuming decisions to making them.│
└──────────────────────────────────────────────────────────────┘
The "use server" Portability
┌──────────────────────────────────────────────────────────────┐
│ SAME DIRECTIVE, DIFFERENT SURROUNDINGS │
│ │
│ The function body: │
│ ┌──────────────────────────────────────────────┐ │
│ │ 'use server'; │ │
│ │ const session = await auth(); │ │
│ │ if (!session) throw new Error(); │ │
│ │ await db.create(...); │ │
│ └──────────────────────────────────────────────┘ │
│ │ │
│ ┌───────────────┼───────────────┐ │
│ ▼ ▼ ▼ │
│ ┌────────────┐ ┌────────────┐ ┌────────────┐ │
│ │ Next.js │ │ Waku │ │ Custom │ │
│ │ │ │ │ │ │ │
│ │ revalidate │ │ No cache │ │ Whatever │ │
│ │ Path() │ │ to clear │ │ you built │ │
│ └────────────┘ └────────────┘ └────────────┘ │
│ │
│ The directive travels. The platform does not. │
└──────────────────────────────────────────────────────────────┘
The Caching Difference
┌──────────────────────────────────────────────────────────────┐
│ WHAT HAPPENS AFTER THE MUTATION │
│ │
│ Next.js Waku │
│ ┌────────────────────┐ ┌────────────────────┐ │
│ │ Action runs │ │ Action runs │ │
│ │ DB mutated │ │ DB mutated │ │
│ │ │ │ │ │
│ │ Cache still holds │ │ No cache. The │ │
│ │ stale page │ │ component re- │ │
│ │ │ │ renders with │ │
│ │ revalidatePath() │ │ fresh data. │ │
│ │ clears it │ │ │ │
│ └────────────────────┘ └────────────────────┘ │
│ │
│ Next.js: explicit invalidation. Waku: no cache to invalidate│
└──────────────────────────────────────────────────────────────┘
Summary
| Item | Value |
|---|---|
| Directive portability | Same syntax across runtimes |
| Implementation stability | Not semver-guaranteed in React 19.x |
| Next.js model | Integrated platform with explicit cache invalidation |
| Waku model | Minimal RSC framework with direct execution |
| Custom bundler model | Primitives provided; integration owned by developer |
| Waku’s missing pieces | No cache, no images, no metadata API, no API routes |
| Custom setup warning | Experimental; many moving parts |
Key takeaways:
- The directive is portable; the platform is not.
"use server"works in Next.js, Waku, and custom setups, but the surrounding APIs—caching, routing, metadata—are framework-specific. A function that callsrevalidatePathis a Next.js function, not a React function. - Next.js makes the most decisions for you. The integrated platform provides caching with an explicit invalidation API, image optimization, metadata, and API routes. The cost is the learning curve of the caching model and the framework’s opinions .
- Waku makes fewer decisions and leaves the rest to you. The minimal framework provides RSC and file-based routing without implicit caching. You assemble metadata, images, and analytics yourself, or use ecosystem libraries. The bundle is smaller because the framework owns less .
- A custom bundler setup is the integration-ownership choice. Libraries like
@mfng/webpack-rscandforketprovide the RSC primitives, but the developer owns the HTTP server, the routing, the build configuration, and the deployment model. The libraries are experimental, and the React implementation APIs are not semver-stable . - The choice is about which decisions you want to own. If you want the platform to decide, choose Next.js. If you want a smaller surface with fewer decisions made for you, choose Waku. If you have existing infrastructure and need complete control, choose a custom setup. The directive works in all three; the experience does not.
Remember: The "use server" directive is the thinnest layer of the RSC model. It marks a function; it does not implement the endpoint, the serialization, the caching, or the deployment. Those are the runtime’s responsibility, and each runtime makes different choices about how much of that responsibility to keep and how much to hand back to the developer. Choosing a runtime is choosing which of those choices you can live with. The directive is the same everywhere. The application around it is not.
Stop using slow, ad-bloated tool sites! 🤮
🔎 Search “KandZ Tools” on Google to use many professional utilities for free.
KandZ.me is the ultimate minimalist hub for:
✅ Finance (Mortgage, Interest, Inflation)
✅ Tech (Base64, JSON, Dev Suite, IP)
✅ Health (BMI, BMR, TDEE)
✅ Productivity (Timer, Workspace, QR)
⚡️ Fast & Private
🔒 No data leaves your device
💎 100% Free
🔗 Use it now: https://tools.kandz.me
🔖 Bookmark it—you’ll need it later!