DEV Community

Discussion on: Different ways to fetch data in Next.js (server-side) and when to use them

Collapse
jameswallis profile image
James Wallis Author

If you want the comments to be updated each time the page loads you need to use getServerSideProps. If you are wanting fast pages use getStaticProps and re-fetch the data once the page has loaded - check out swr.vercel.app/ which is a React hook that can help with this.

Collapse
cucheng profile image
Trương Đình Chiến

Tks bro, i still using swr to fecth data from api.But i think post list should use getStaticProps togenerated at build time and will be reused on each request.

Thread Thread
jameswallis profile image
James Wallis Author

Yeah that sounds sensible.