Functions

Pages getStaticProps

Pages-only data function for static prerendering and regeneration. Export it from the page itself. Its returned props must be serializable and safe to expose to browsers. A positive revalidate value sets a minimum regeneration interval; requests and successful regeneration govern freshness. This public catalog uses synthetic titles. Source: https://nextjs.org/docs/pages/api-reference/functions/get-static-props. Documentation-reviewed illustrative draft; installed declarations and runtime not verified.

Formal Syntax & Structure

nextjs syntaxnextjs
export const getStaticProps: GetStaticProps = async (context) => ...

Working Example

Example Snippetnextjs
// pages/catalog/index.tsximport type { GetStaticProps, InferGetStaticPropsType } from 'next';export const getStaticProps = (async () => ({props:{titles:['Fern Atlas','River Walk']}, revalidate:120})) satisfies GetStaticProps<{titles:string[]}>;export default function Catalog({titles}: InferGetStaticPropsType<typeof getStaticProps>) { return <main><h1>Catalog</h1><ul>{titles.map(title=><li key={title}>{title}</li>)}</ul></main>;}
Next.js Reference