The 5 Most Common Next.js App Router Mistakes And How to Fix Them
The Next.js App Router is powerful — layouts, React Server Components, Server Actions, caching, streaming — but most developers hit the…
The 5 Most Common Next.js App Router Mistakes And How to Fix Them
The Next.js App Router is powerful — layouts, React Server Components, Server Actions, caching, streaming — but most developers hit the same handful of mistakes when they start using it in real projects.
Here are the 5 most common pitfalls I see over and over — and how to fix them immediately.
1. Putting Client Components Where They Don’t Belong
The mistake:
Wrapping entire pages in "use client" because something “doesn’t work.”
// ❌ Don't do this
"use client";
export default function Page() {
return <Dashboard />;
}
This forces the whole subtree to become client-side, disabling:
- server-side data fetching
- automatic caching
- reduced bundle size
- streaming
Correct approach: Only make the smallest component client-side.
export default function Page() {
return (
<div>
<h1>Dashboard</h1>
<ChartClientComponent />
</div>
);
}
2. Forgetting That fetch() Is Cached by Default
Default caching surprises everyone at least once.
// ❌ This will be cached forever by default
const data = await fetch("https://api.example.com/stats").then(r => r.json());
Symptoms:
- Your UI doesn’t update
- Stale results
- Data appears “stuck”
Fix: Decide intentionally how you want to cache it:
Disable caching
await fetch(url, { cache: "no-store" });
Set revalidation
await fetch(url, { next: { revalidate: 10 } });
Force one-time server fetch
await fetch(url, { cache: "no-cache" });
This alone fixes 80% of “why is my data stale?” issues.
3. Misusing Layouts for Stateful Logic
Layouts are shared, meaning they do not remount between routes.
Common mistake:
// ❌ layout.tsx
"use client";
export default function RootLayout({ children }) {
const [count, setCount] = useState(0); // persists between pages!
}
This leads to:
- State leaking between pages
- UI not resetting
- Confusing behavior
Fix: Only put system-level or global UI in layouts:
- Theme provider
- Navbar
- Footer
- Auth wrappers
- Global CSS
Anything interactive should live in the page or a client component inside the page.
4. Using Route Handlers for “Everything”
Some devs treat /api/* like a traditional backend.
// ❌ next.js is NOT a full Express replacement
app.get("/api/users", ...)
But Route Handlers are best for:
- simple CRUD
- server actions helpers
- webhooks
- simple utilities
They are not meant for:
- complex request routing
- authentication middlewares
- chained middlewares
- big monolithic APIs
Fix: If the logic is heavy:
- Use server actions for UI-driven mutations
- Use a dedicated backend for large APIs
- Or keep Route Handlers tight by splitting logic into modules
5. Triggering Revalidation Incorrectly
Many beginners assume revalidatePath() updates everything everywhere.
It doesn’t.
Example mistake:
"use server";
export async function updatePost() {
await db.post.update(...);
revalidatePath("/");
}
But the stale data is inside:
/posts/[id]
Fix: You must revalidate the exact path or segment:
revalidatePath(`/posts/${id}`);
Or if the data affects a layout segment:
revalidatePath("/posts", "layout");
General rule:
Revalidate the closest segment where the data is fetched.
Conclusion
These five issues cause 90% of App Router confusion:
- Misplaced client components
- Confusing
fetch()caching - Stateful logic inside layouts
- Overusing Route Handlers
- Incorrect revalidation patterns
Fix these, and your Next.js app will become:
- faster
- cleaner
- more predictable
- more scalable
메타데이터
- post_id
- 632565a5fb96
- slug
- the-5-most-common-next-js-app-router-mistakes-and-how-to-fix-them-632565a5fb96
- url
- https://medium.com/@amirjld/the-5-most-common-next-js-app-router-mistakes-and-how-to-fix-them-632565a5fb96
- canonical_url
- https://medium.com/@amirjld/the-5-most-common-next-js-app-router-mistakes-and-how-to-fix-them-632565a5fb96
- author_url
- https://medium.com/@amirjld
- status
- ok
- fetched_at
- 2026-06-12 18:14:10