Nextjs and the Great Static Gatsby - 401-advanced-javascript-aimurphy/seattle-javascript-401n13 GitHub Wiki
To Gatsby or not to Gatsby...
A static site generator generates static HTML on build time. It doesn’t use a server.
With server-side rendering, it dynamically generates the HTML every time a new request comes in. It uses a server for this.
Gatsby is a static site generator tool.
Next is mainly a tool for server-side rendered pages (although it also supports static exports)
Of course, both can call APIs client side. The difference is Next requires a server to be able to run. Gatsby can function without any server at all.
Gatsby just generates pure HTML/CSS/JS. This means you can host it at S3, Netlify or other static hosting services. This makes it extremely scalable to high traffic loads.
Next creates HTML on runtime. So each time a new request comes in, it creates a new HTML page from the server.
Gatsby | Next | |
---|---|---|
SPA(single page app) | yes | yes |
SEO(search engine optimized) | yes | yes |
Supports any kind of websites | yes | yes |
Learning curve | React + Graphql + few Gatsby apis | React + few Next.js apis |
Final HTML code generation | In the ‘build’ process (continuous integration and continuous delivery CI/CD server) | In the server |
Output | HTML + CSS + JS files | HTML + CSS + JS files + Node.js code to serve these files |
Supports Netlify (or any static hosting sites) | yes | No (yes, if only using static export) |
Requires server | no | yes |
Data handling | Gatsby dictates how you should handle data in your app: GraphQL | up to you! |