Skip to content

Next.js & Reader API — Dynamic routes missing on deployed site (Vercel) #950

Answered by simonswiss
unkleho asked this question in Q&A
Discussion options

You must be logged in to vote

Hey!

Neither a Keystatic nor a Vercel issue — this is a result of building your Next.js site with static pages.

Whenever you want to have dynamic path segments (which you do), the HTML pages for each entry need to be generated at build time with generateStaticParams.

If you add this export to your [slug] route, the individual post pages will start working.

It's pretty easy to do with the Reader API, since all you need to export is an array of slugs, which you can get with reader.collections.myCollection.list().

Here's an example from the Keystatic docs website, to generate all static docs pages:

https://github.com/Thinkmill/keystatic/blob/main/docs/src/app/(public)/docs/%5B...slug%5D/page…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@unkleho
Comment options

Answer selected by unkleho
Comment options

You must be logged in to vote
1 reply
@needim
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #949 on February 11, 2024 23:37.