Client-side cache of visited route segments.
Skip to solutionKEEP THE
hardFrontend
What is the Router Cache in Next.js and what are its implications?
581 views
01
Understand the problem
nextjsrouter-cachecachingnavigation
02
Attempt it yourself
Sketch your approach before reading the solution — that's what interviews test.
Nudge consolestandby
Stuck? Beam a request up — the console returns a conceptual nudge that guides your logic without spoiling the implementation.
03
Study the solution
The Router Cache (client-side) stores the RSC payload of visited/prefetched routes for the session, giving instant back/forward navigation. Its staleness can show outdated data after a mutation, so you call router.refresh() or revalidate to update it.
Solution ready — 2 min read
Classified // press E to declassify
04
Read the code
Refresh the Router Cache after a mutation
'use client';
import { useRouter } from 'next/navigation';
function DeleteButton({ id }) {
const router = useRouter();
return <button onClick={async () => {
await fetch('/api/items/' + id, { method: 'DELETE' });
router.refresh(); // re-fetch current route's server data (clears stale UI)
}}>Delete</button>;
}05
Join the discussion
Discussion (0)
Sign in to join the discussion.
No responses yet. Be the first to share what you think.
Transmission complete // awaiting log
KEEP THE
STREAK ALIVE.
Dossier 85 of 95 decoded in the Next.js track. One more won't hurt.