Next.jsMedium

What is cache: 'no-store' used for in fetch?

cache: 'no-store' tells Next.js to fetch fresh data from the source on every request and never store the response in the Data Cache. It is how you opt a request out of caching in the previous caching model.

Behavior

  • The request always goes to the network.
  • In the previous model, using it makes the route dynamic: rendered per request instead of prerendered.
  • Request memoization still applies within one render, so the same no-store URL is only called once per render.

Is it still needed?

  • Next.js 15 and later: fetch is not cached by default, so no-store mostly documents intent. It still matters when a route sets a caching default, for example fetchCache = 'default-cache', or when you want to make dynamic rendering explicit.
  • Next.js 14 and earlier: essential, because fetch defaulted to force-cache.
  • With Cache Components: a plain fetch is already uncached request-time work; put the component behind <Suspense>. If you want to force request-time rendering for non-fetch work like Math.random() or Date.now(), use await connection() instead.

Typical uses

Live stock levels, account balances, prices that must be exact, and anything per-user from an external API.

Alternatives

  • next: { revalidate: 0 } has the same effect.
  • export const dynamic = 'force-dynamic' made the whole route dynamic in the previous model; remove it when adopting Cache Components.

Code example

tsx
1// app/account/balance.tsx
2import { cookies } from "next/headers";
3
4export async function Balance() {
5 const token = (await cookies()).get("token")?.value;
6
7 // Always fresh: never cached, never shared between users
8 const res = await fetch("https://bank.example.com/balance", {
9 cache: "no-store",
10 headers: { Authorization: `Bearer ${token}` },
11 });
12 const { amount } = await res.json();
13
14 return <p>Balance: ${amount}</p>;
15}
16
17// app/account/page.tsx
18// import { Suspense } from "react";
19// export default function Page() {
20// return (
21// <Suspense fallback={<p>Loading balance…</p>}>
22// <Balance />
23// </Suspense>
24// );
25// }

Practice this question

Open it in the study app to track progress, take notes, listen to the answer and work through the rest of the Next.js set.

Open in study app