getServerSideProps() — Nextjs — Data Fetching
Nov 6, 2023
When you use getServerSideProps
in a page component, the data fetching code you place inside it runs on the server side when the page is requested. This is useful for scenarios where you need to fetch data on each request, such as data that frequently changes or data that is specific to the user's request.
There is only one benefit to use getServerSideProps() instead of using getStaticProps() and that is fetching data for every single incoming request if you dont have data that changes frequently using getStaticProps() might be better.