DEV Community

Discussion on: Gatsby vs Next.JS - What, Why and When?

Collapse
 
dechowmedia profile image
Lucas Dechow

One thing I do wan't to mention (that sadly the article does not reflect)
Is the fact you can actually export your NextJS application as a static rendered app.

nextjs.org/features/static-exporting

And the documentation does also reflect this.
nextjs.org/docs#static-html-export

There are some limitations but generally you can copy just the dist folder and you have the app statically generated :)

(though there is some more to it, but it is not that hard, and pretty much reflects the same process as Gatsby)

Collapse
 
stackoverprof profile image
R.Bintang Bagus Putra Angkasa

sadly but true, after exported, dynamic routing like [somewhat].js path will not be working out-of-the-box :(

Collapse
 
dechowmedia profile image
Lucas Dechow

Hi @stackoverprof

Are you meaning that [somewhat].js is not working?
You have to precalculate the routes (or rather the possible outcomes of the route) for it to be exporting the specific pages - this is particularly done if the fallback is set to false:
nextjs.org/docs/basic-features/dat...

It will return a 404 (naturally) unless you specify the pages for export:
nextjs.org/docs/basic-features/dat...

If however you want to have some paths statically generated and then dynamically generate the rest (think a large ecommerce site, or blog/dynamic pages on a otherwise statically generated site) - you can use the fallback: true (as it will fallback to data fetching)
See this for more info:
nextjs.org/docs/basic-features/dat...

Thread Thread
 
stackoverprof profile image
R.Bintang Bagus Putra Angkasa

Thankyou