Home > Enterprise >  Where does Next JS stores the statically generated website and How Next JS app serving is different
Where does Next JS stores the statically generated website and How Next JS app serving is different

Time:10-05

Next JS by default generates a static version of the website after building it the first time and then serves it when the user requests it. Wouldn't that be opposite of what ReactJS does (Where React JS uses JS to generate the website at the client's end.) and basically would be same as using vanilla HTML/CSS/JS?

Also, Where does Next JS stores the statically generated website? (Is it at the server where the website is hosted or somewhere else?)

CodePudding user response:

Yes, it sounds a little counter-intuitive, so NextJS actually generates HTML markdown from react components, but the idea is to make it faster in the first-page load, but after that, the app will end up sending the rest of the javascript like a normal ReactJS app.

The objective of this is to respond to HTML always (so google and other SEO tools can "understand" your page without loading extra assets).

That HTML travels in the HTTP request and gets loaded to the page, but after that the real ReactJS gets loaded, adding interaction to those initial components loaded directly from HTML (that process is called hydration).

The statically generated files are built by NextJS on deployment, these files can be served by NextJS itself (when running on a self-hosted environment), or they can be uploaded to a more conventional website hosting solution.

  • Related