Category: Next.js, React and TypeScript

Next.js: new article 404 by dynamicParams = false

Read this guide in Polish

After adding the article to the data /guides/new returns 404, although older service works. The dynamicParams=false option limits the support of segments to the values given by generationStaticParams at build.

How to identify the source of the problem

Read the dynamicParams value in the route file and the service list returned by generationStaticParams. Compare SHA of the production deployment with the addition of the article and determine whether the new slug was in the build.

Compare the message from the console with the result of the production compilation and the condition after the page has been refreshed.

Repair steps

For a site that publishes new services without full rebuild, set consciously dynamicParams=true and proper cache. If you are using fully static exports, generate all the necessary parameters when building and start a new deployment after publication.

How to Test Solution

The new article returns 200 under its own URL, and the unknown slug continues to return the real 404.

Security and restrictions

Do not direct all unknown service to one replacement article with code 200.