This page renders fresh on every single request. Refresh the page — the timestamp updates each time. The server has access to cookies, headers, and can fetch personalized data.
↑ Refresh the page — this timestamp changes every time. That's SSR.
↑ This data only exists server-side. You can't access raw headers in a Client Component.
// Force SSR by opting out of caching
export const dynamic = "force-dynamic";
// OR use: fetch('url', { cache: 'no-store' })
import { cookies, headers } from "next/headers";
export default async function SSRPage() {
// Access request-scoped data
const cookieStore = cookies();
const token = cookieStore.get("session");
// Fetch user-specific data
const user = await getUserById(token?.value);
return <Dashboard user={user} />;
}export async function getServerSideProps(context) {
const { req, res, params } = context;
const token = req.cookies.session;
const user = await getUser(token);
return { props: { user } };
}// SSG: runs ONCE at build time
const data = await fetch("https://api.example.com/data");
// cache: 'force-cache' (default) ↑
// SSR: runs on EVERY request
const data = await fetch("https://api.example.com/data",
{ cache: "no-store" } // ← this one line changes everything
);