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

Viewed 180

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?

1 Answers

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 pages using Static Generation without fetching data.

(...) In cases like this, Next.js generates a single HTML file per page during build time.

Related