Skip to content
Latchkey

Next.js "missing exported function getStaticPaths" - Fix in CI

A dynamic Pages Router route ([id].tsx) that exports getStaticProps must also export getStaticPaths so Next knows which paths to pre-render. Missing it fails the build.

What this error means

The build fails with Error: getStaticPaths is required for dynamic SSG pages and is missing for <route>.

next
Error: getStaticPaths is required for dynamic SSG pages and is missing
for '/product/[id]'.

Read more: https://nextjs.org/docs/messages/invalid-getstaticpaths-value

Common causes

getStaticProps without getStaticPaths

The dynamic route opts into static generation via getStaticProps but never declares which params to build.

Wrong rendering choice

The page should be server-rendered or use fallback rendering instead of full SSG.

How to fix it

Add getStaticPaths

  1. Export getStaticPaths returning the params to pre-render and a fallback mode.
[id].tsx
export async function getStaticPaths() {
  return { paths: [{ params: { id: '1' } }], fallback: 'blocking' };
}

Switch to server rendering

  1. If paths are not known at build time, use getServerSideProps instead.
[id].tsx
export async function getServerSideProps(ctx) {
  return { props: { id: ctx.params.id } };
}

How to prevent it

  • Pair getStaticProps with getStaticPaths on every dynamic SSG route.
  • Pick a rendering strategy explicitly per route.

Frequently asked questions

What causes "getStaticPaths"?
The dynamic route opts into static generation via getStaticProps but never declares which params to build.
How do I fix getStaticPaths?
Add getStaticPaths

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card