-
Good day everyone, I'm working on a website which fetches data from a headless CMS. Most of the website's There is an article system which changes every time the client posts a new article.
There are some tabular board member data which changes from time to time.
Static content should be pulled from the CMS as well,
If I'm using According to the documentation, I can pass a Is this the best way to achieve what I'm trying to do? What are the best practices in situations like this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Nope! As you found out, using export async function getStaticProps({ params }) {
// params contains the post `id`.
// If the route is like /posts/1, then params.id is 1
const res = await fetch(`https://.../posts/${params.id}`)
const post = await res.json()
// Pass post data to the page via props
return {
props: { post },
// Re-generate the post at most once per second
// if a request comes in
revalidate: 1,
}
} You can change the Docs: https://nextjs.org/docs/basic-features/data-fetching#incremental-static-regeneration |
Beta Was this translation helpful? Give feedback.
-
Very cool. Thanks for your answer. |
Beta Was this translation helpful? Give feedback.
Nope! As you found out, using
revalidate
is the perfect solution for your problem. For example:You can change the
revalidate
value depending on …