SSG + ISR через getStaticProps/getStaticPaths; API routes — Node req/res style.
Пример
export async function getStaticPaths() {
const slugs = await getAllSlugs();
return {
paths: slugs.map((slug) => ({ params: { slug } })),
fallback: 'blocking',
};
}
export async function getStaticProps({ params }) {
const post = await getPost(params.slug);
if (!post) return { notFound: true };
return { props: { post }, revalidate: 60 };
}
export default function Post({ post }) {
return {post.title};
}
export default function handler(req, res) {
if (req.method !== 'GET') return res.status(405).end();
res.status(200).json({ name: 'Ada' });
}
Итог
Pages pattern: data functions on page file + ISR revalidate; API — (req, res) handler.