Home > front end >  NextJS server side rendering
NextJS server side rendering

Time:01-04

I'm building an app using NextJS and its server side rendering feature.

If I understood it correctly, to take advantage of it all we need to do is exporting an async function called getServerSideProps in the component we want to server side render.

Curious thing is I noticed my components were being server side rendered even without exporting getServerSideProps function.

Is there any other thing (other than getServerSideProps) that can cause a component to be server side rendered?

Thanks in advance

CodePudding user response:

In NextJS as you can see here, the default behaviour is Static Generation : https://nextjs.org/docs/basic-features/pages#static-generation-without-data

In version 13 : https://beta.nextjs.org/docs/rendering/static-and-dynamic-rendering

CodePudding user response:

NextJS will always render on the server (and hydrate again on the client). However, without dynamic data from getServerSideProps it can already be rendered during the build and then cached. With getServerSideProps the page will be rendered anew with the up-to-date data for every request by a user. In this case the page will be rendered in a Serverless function.

  • Related