
Next.js App Router (Next.js 13.4+) fuses React Server Components and Client Components into a single tree. Most of the time this works invisibly, but when it breaks, the errors are cryptic and the stack traces point to internals you've never touched. This guide gives you the concrete techniques to diagnose every class of boundary failure quickly.
Diagnose Error #418, #423, #425 & get copy-paste code diffs
Paste Next.js or React hydration error logs to instantly diagnose server-client HTML mismatches (dates, localStorage, extension injection) and generate safe fixes.
Server Components run only on the server: they can await database calls, read env vars, and import Node.js-only modules. Their output is serialized as the RSC payload - a compact, streaming format that is not HTML, not JSON, and not JavaScript bundles. Client Components (marked 'use client') compile to browser JS and run during hydration and re-renders.
The boundary is the edge where a Server Component renders a Client Component. Anything crossing that edge must be serializable.
What you see:
Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server".
at stringify (...next/dist/server/app-render/app-render.js:...)
Or for class instances:
Error: Only plain objects, and a few built-ins, can be passed to Client Components from Server Components.
Classes or null prototypes are not supported.
What causes it: Passing a Date, Map, Set, a class instance, or a function as a prop from a Server Component to a Client Component.
// ❌ Date object is not serializable
async function Page() {
const post = await db.post.findFirst()
return <PostCard publishedAt={post.createdAt} /> // Date → crash
}
// ✅ Serialize to ISO string before passing
async function Page() {
const post = await db.post.findFirst()
return <PostCard publishedAt={post.createdAt.toISOString()} />
}
Debugging tip: Log JSON.stringify(yourProp) in the Server Component before passing it. If it throws or produces {}, that prop isn't serializable.
What you see in the browser console:
Error: Hydration failed because the initial UI does not match what was rendered on the server.
Warning: Expected server HTML to contain a matching <div> in <div>.
See more info here: https://nextjs.org/docs/messages/react-hydration-error
Root cause: The HTML sent from the server does not match the React tree the client renders during hydration. Common triggers:
window, localStorage, navigator, or Date.now() in a Client Component's initial renderFix pattern - defer browser-only code:
'use client'
import { useEffect, useState } from 'react'
// ❌ Crashes: window is undefined on the server
export function ViewCount() {
const stored = localStorage.getItem('views') ?? '0'
return <span>{stored} views</span>
}
// ✅ Mount-safe: reads localStorage only after hydration
export function ViewCount() {
const [views, setViews] = useState<string | null>(null)
useEffect(() => {
setViews(localStorage.getItem('views') ?? '0')
}, [])
if (views === null) return <span>- views</span>
return <span>{views} views</span>
}
Fix for date mismatches: Always pass dates as ISO strings from the server and parse them client-side using new Date(isoString). Don't call new Date() inside a Client Component's initial render.
Before Next.js even hydrates, it streams the RSC payload from the server. You can inspect it raw to understand what the server sent.
Open DevTools → Network tab → filter by Fetch/XHR → reload the page. Look for requests to your page URL with Accept: text/x-component. The response looks like:
0:["$","div",null,{"className":"prose"},["$","h1",null,{},"Hello"]]
1:{"id":"cjld2cyuq0000t3rmniod1fga","title":"Hello World","createdAt":"2026-01-01T00:00:00.000Z"}
This tells you exactly what data the server serialized and what tree shape it produced. If a field is missing here, it was either not fetched or was stripped as non-serializable.
Pro tip: In Next.js dev mode, add ?_rsc=1 to the URL to force a pure RSC refresh and inspect the payload in isolation.
What you see:
Module build failed: You're importing a component that needs "server-only"
but none of its parents are marked with "use server", nor are they a Server Component.
Or worse - no error, just a Node.js API call that silently returns undefined in the browser bundle.
The server-only package is the canonical guard:
npm install server-only
// lib/db.ts
import 'server-only' // ← throws at build time if imported in a Client Component
import { PrismaClient } from '@prisma/client'
const db = new PrismaClient()
export { db }
Now if any Client Component or a file it imports tries to import lib/db.ts, the build fails with a clear error instead of silently shipping your database credentials to the browser.
Apply this to any file that:
fs, crypto, net, etc.)use server Function Boundary'use server' on a function (not a file) creates a Server Action - a function that runs on the server but can be called from a Client Component. The rules are strict:
// app/actions.ts
'use server'
export async function createPost(formData: FormData) {
const title = formData.get('title') as string
if (!title) throw new Error('Title is required')
await db.post.create({ data: { title } })
}
Common mistakes at the use server boundary:
'use server'
import { z } from 'zod'
const schema = z.object({ title: z.string().min(1).max(200) })
export async function createPost(formData: FormData) {
const parsed = schema.safeParse({ title: formData.get('title') })
if (!parsed.success) throw new Error('Invalid input')
await db.post.create({ data: parsed.data })
}
useActionState to capture the error state:'use client'
import { useActionState } from 'react'
import { createPost } from './actions'
export function PostForm() {
const [error, action, isPending] = useActionState(
async (_prev: string | null, formData: FormData) => {
try {
await createPost(formData)
return null
} catch (e) {
return (e as Error).message
}
},
null
)
return (
<form action={action}>
<input name="title" />
{error && <p className="text-red-500">{error}</p>}
<button disabled={isPending}>
{isPending ? 'Saving…' : 'Create Post'}
</button>
</form>
)
}
React 19 introduces experimental_taintObjectReference and experimental_taintUniqueValue to prevent accidentally passing sensitive server data to Client Components:
// app/api/user/route.ts
import { experimental_taintObjectReference } from 'react'
async function getUser(id: string) {
const user = await db.user.findUnique({ where: { id } })
// Mark the whole object as tainted - passing it as a prop will throw
experimental_taintObjectReference(
'Do not pass user objects to Client Components. Serialize only the fields you need.',
user
)
return user
}
Enable in next.config.js:
/** @type {import('next').NextConfig} */
module.exports = {
experimental: {
taint: true,
},
}
This is a defense-in-depth measure - the error fires at render time in development, before any accidental data leaks to the client bundle.
'use client' Placement StrategyThe most impactful performance decision in App Router is where you draw the client boundary. A common mistake is placing 'use client' on a layout or high-level page component, which forces every child into the client bundle.
Rule: Push 'use client' as deep as the interactivity actually needs to go.
// ❌ Forces everything into client bundle
'use client'
export default function BlogPage({ posts }) {
const [filter, setFilter] = useState('')
return (
<div>
<input onChange={(e) => setFilter(e.target.value)} />
{posts.map(p => <PostCard key={p.id} post={p} />)}
</div>
)
}
// ✅ Only the filter widget is a Client Component
// BlogPage and PostCard remain Server Components
'use client'
export function FilterInput({ onFilter }: { onFilter: (q: string) => void }) {
return <input onChange={(e) => onFilter(e.target.value)} />
}
Server Components can pass other Server Components as children through Client Components without making them client-side:
// This pattern works - children are still Server Components
export default function Layout({ children }: { children: React.ReactNode }) {
return <ClientShell>{children}</ClientShell>
}
| Symptom | First check | Tool |
|---|---|---|
| "Functions cannot be passed" | Prop types crossing boundary | JSON.stringify(prop) in Server Component |
| Hydration mismatch | Browser-only APIs in initial render | DevTools → React tab → Hydration errors |
| RSC payload wrong | What the server actually serialized | Network tab → text/x-component request |
| Server module in browser | Missing server-only import | Build output → bundle analyzer |
| Action fails silently | Uncaught throw in Server Action | useActionState error capture |
| Sensitive data leaks | Object passed to Client Component | experimental_taintObjectReference |
A Next.js application uses the App Router. A Server Component fetches a `Post` object from a database, which includes a `createdAt` field of type `Date`. This `Post` object is then passed as a prop to a Client Component `PostDisplay`. Which of the following approaches will successfully prevent a `Non-Serializable Props` error while ensuring the `createdAt` date is displayed correctly to the user?
Clean AI CLI logs, build cron expressions, decode JWTs, and calculate chmod permissions offline.

A deep dive into managing forms in Next.js 14 using Server Actions, useFormState, useFormStatus, and Zod for schema validation. Learn to build modern, progressive-enhanced forms without client-side JavaScript fatigue.
Read more
How to fix Minified React Error #418, #423, and hydration text mismatches in Next.js 14/15. Complete solution for browser extensions and suppressHydrationWarning.
Read more
Safe usage of suppressHydrationWarning in Next.js: when to use it, why browser extensions trigger warnings, and how to fix root mismatch issues cleanly.
Read more