// Pages Router
export async function getStaticProps() {
const posts = await getPosts();
return { props: { posts }, revalidate: 60 };
}
// App Router
export const revalidate = 60;
export default async function Page() {
const posts = await getPosts();
return <PostList posts={posts} />;
}
They are the Pages Router's data functions. In the App Router, async Server Components and a few exports replace them.
In the Pages Router:
getServerSidePropsruns on every request and passes props to the page.getStaticPropsruns at build time. With arevalidatevalue, it enables ISR (Incremental Static Regeneration: rebuilding the static page in the background).getStaticPathslists which dynamic paths to prerender. Itsfallbackoption controls unknown paths.
In the App Router:
- The page itself is an async Server Component that fetches its own data.
- Static rendering is the default.
- Request-time rendering happens when you use dynamic APIs (request-time APIs like
cookies()orsearchParams), or setdynamic = "force-dynamic". - ISR uses
export const revalidate, orfetchwithnext.revalidate. generateStaticParamsreplacesgetStaticPaths.dynamicParamsreplacesfallback.
getServerSidePropsruns on every request,getStaticPropsruns at build time, andgetStaticPathslists which paths to prerender.- In the App Router, async Server Components fetch their data directly.
- Dynamic APIs or
force-dynamicreplacegetServerSideProps. - An exported
revalidatereplaces therevalidateoption ofgetStaticProps. generateStaticParamsreplacesgetStaticPaths, anddynamicParamsreplacesfallback.