COVID-19 Dashboard (Dutch) #13407
-
First off, sorry it's in Dutch, but it's mostly numbers so you will understand. After my last project, which was made with Nextjs, I fell in love with it. It was the first time I used Nextjs. Due to the requirements, we could not get the most out of the SSR. I decided to make a small project, and learn to get the most out of the SSR with Nextjs. Link to the project: For now, the website uses a big json file with all the data. It imports it with getStaticProps. I have to update this data every day for now, which only takes me 30seconds or so, but I would like to make an api it could receive it from. One question: If the data changes once a day, would you suggest using getStaticProps with the above approach, or suggest using getServerSideProps to call an api. What do you think? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
SSG is an excellent choice here, take a look into the RFC for Incremental Static Regeneration. If the data gets updated once per day, or every 30 minutes, or every second, doesn't matter; you can revalidate the page in the background after X amount of time and start shipping the latest HTML after that. For example, to revalidate the page every hour: export async function getStaticProps() {
// ...
return {
props: {...},
unstable_revalidate: 3600 // 3600 seconds = 1 hour
}
} The |
Beta Was this translation helpful? Give feedback.
SSG is an excellent choice here, take a look into the RFC for Incremental Static Regeneration. If the data gets updated once per day, or every 30 minutes, or every second, doesn't matter; you can revalidate the page in the background after X amount of time and start shipping the latest HTML after that.
For example, to revalidate the page every hour:
The
unstable_revalidate
option will be shipped soon and it's safe to use it now 👍 - once it's out it will be renamed torevalidate