Parvesh Goyal
Parvesh Goyal

Reputation: 53

How is page rendered if neither getStaticProps nor getServerSideProps is created in a page?

I have an existing project built with Next.js but none of the two rendering methods are defined in some of the pages.

How are those pages rendered if neither getStaticProps nor getServerSideProps are present?

Upvotes: 3

Views: 938

Answers (1)

juliomalves
juliomalves

Reputation: 50308

If a page does not contain any data fetching methods (getStaticProps/getServerSideProps) then it will use static generation. This means Next.js generates the page HTML at build time, this HTML will then be reused on each request to the page.

From the Static Generation without data documentation:

By default, Next.js pre-renders every page. This means that Next.js generates HTML for each page in advance, instead of having it all done by client-side JavaScript.

Upvotes: 5

Related Questions