Gatsby vs. Next.js
GatsbyJS meetup
Prague, 14 Nov 2019
I am a software engineer
... forced to make websites
2000's & most of 2010's:
blogs → WordPress
simple sites → plain HTML
It was both ✌ and 🤕
WordPress
✅ Complex sites quickly
✅ Themes & plugins
✅ Lots of resources
WordPress
🙁 Ugly old codebase
🐌 Slow by default
😭 No version control
Plain old HTML
Confession: I actually enjoyed it
Plain old HTML
... but was really unproductive with it
In the meantime, React ⚛ happened
I quickly fell in love
We adopted it for VersionPress' UI in 2015
... and built a VP.com dashboard with it
We were building apps in React
But websites were still WordPress & plain HTML
2018: Gatsby explodes 💥
I'm trying it for our VP.com website
❤❤❤ SPEEED ❤❤❤
no servers to manage hack
React ⚛
New kind of experience ⇒ questioning old truths
🤔 Why do we build SPAs?
<!DOCTYPE html><!DOCTYPE html>
<<htmlhtml langlang==""enen"">>
<<bodybody>>
<<divdiv idid==""rootroot"">></</divdiv>>
<<scriptscript typetype==""text/javascripttext/javascript"" srcsrc==""/static/vendors.js/static/vendors.js"">></</scriptscript>>
<<scriptscript typetype==""text/javascripttext/javascript"" srcsrc==""/static/app.js/static/app.js"">></</scriptscript>>
</</bodybody>>
</</htmlhtml>>
Why are we serving this to our users?
But we kept at it.
2019: New project
Would Gatsby be a good fit?
By "SSR", Gatsby means build-time pre-rendering
Dear sirs, SSR !== pre-rendering. Best regards, Borek
It felt quite poor in comparison:
Barebones (no plugin system, no themes, ...)
No universal data layer via GraphQL
Fewer optimizations out of the box
But it had SSR
and eshops abso-freakin-lutely need SSR
Next.js also felt better than other choices
So we tried it
... and it felt really good!
(see the pattern? ❤❤❤)
Being barebones was a benefit for Shoptet's platform
Data fetching however we wanted
(we chose GraphQL anyway 😄 )
The best runtime model I've seen to date
Source
ZEIT Now deployments 😍
▲
So...
When to use which?
1. For static sites, I'd use Gatsby
Easily combine data from multiple sources
Markdown
WordPress
`gatsby-source-*`
Many plugins available
Great performance
2. For apps, I'd use Next
See e.g. Kap
Next.js has almost no downsides
compared to plain React app / CRA
3. For complex / dynamic sites, clearly Next
Both pre-rendering (ala Gatsby) and SSR
Not too complex, not too simple
Super-powers when combined with Now ▲
But most importantly...
Both are ⚛
⚛
One set of skills
Code is 95% the same
Both built on React, Babel, webpack, ...
(4. For a slide deck, I'd use Gatsby & mdx-deck 😄 . Repo.)
Thank you!
--
@borekb

Gatsby vs. Next.js