1

I have a page that display hotel information by id, so I use getStaticPath to create thing like /hotel-info/542711, 542711 is hotel-id

Problem is There are thousands of hotels, And NextJS will pre-build all that thousands page???? (Increment Static Generation)

Is there problem with memory due to store too much pre-built page like that? ...

DucHT
  • 361
  • 1
  • 3
  • 10
  • You don't necessarily have to pre-generate _all_ the possible paths during build time (you can select only a subset). You can leverage `getStaticPaths` with `fallback: 'blocking'`, see [How to add new pages without rebuilding an app with +150k static pages?](https://stackoverflow.com/questions/66036558/how-to-add-new-pages-without-rebuilding-an-app-with-150k-static-pages). – juliomalves Jul 18 '22 at 22:43

1 Answers1

0

GetStaticPaths() pre-renders all the paths only at build time.

And depending if you choose or not to pre build all of them, then yes, you could have a thousand pages pre built in your build folder.

So unless perfomances are very very important to you and you have you own a data center to store all of that, I wouldn't recommand doing that.

You don't have to use GetStaticPath() and you if you do, you should use it wisely.

A good use case for this would be to generate only your most popular pages and leave your less popular ones to be generated once they are actually visited for the first time.

Topsy
  • 1,023
  • 1
  • 11
  • 26