Next.js vs Gatsby – Which One To Choose?

Share

Server-side rendering for React apps gave birth to many great features, possibilities, and tool like Gatsby.js and Next.js

It became an extremely popular topic, mostly because of all the blessings it gives to web app development, user experience improvements, and the ability to support digital marketing efforts more efficiently.

Meanwhile, we’ve also been introduced to JAMStack – a web development architecture that makes scaling up much easier.

In the world of React JAMStack, we have two main competitors: Gatsby.js and Next.js.

Both do great things, both are growing up quickly, both are loved by developers, and unconsciously by users.

The question remains: which one is better to work with? And, of course, in which case?


Next.JS & Gatsby are the kings of the JAMstack world

If you want to build a React powered and indexed by Google web application you will need to choose between Gatsby & Next JS which are the most popular tools to do this job.

Of course, choosing the right tech stack depends on your project requirements, but let’s assume you want to build a JAMStack website that needs to be:

  • Indexed by Google, because you want to grow your organic traffic,
  • Performant, because you want to provide the best user experience possible,
  • Written in React, because of its component-based approach for building user interfaces,
  • Integrated with a headless CMS because you need to be able to change content frequently,
  • PWA (progressive web app) ready.

Let’s see how both can help us achieve the desired result.


Similarities between Gatsby.js and Next.js

Performant, accessible, and SEO friendly websites.

Thanks to SSG or SSR in both tools, your web app can be indexed in Google much easier.

This enables you to attract many more visitors through organic search traffic.

To rank higher:

  • your content needs to be well written and SEO optimized,
  • you need to provide a great user experience for your visitors,
  • you need to take care of website speed metrics.

And this is where performance really matters.

Gatsby is a perfect tool for achieving performance results, as it is statically generating HTML for final users (and in fact also search engines).

But not to leave the competitor behind, exactly the same thing is possible with NextJS.

So in case of performance, both allow us to achieve truly outstanding results.

React behind

Both Gatsby and Next are using React JS so you can benefit from all of the cool stuff like:

  • Component-based approach,
  • a lot of UI kits available that can shorten the time for development,
  • wide access to developers,
  • great DX – developer experience (devs like to work with React),
  • and much more.

The question arises:

why do I even need GatsbyJS or NextJS? isn’t React good enough?

To put it very simple, React by itself works only on the client-side (your browser) and does not provide server-side rendering. In other words, it does not provide all the super speed and SEO blessings at the level of Gatsby or Next.

P.S. If you want to check how React can impact your business, have a look at our report:

JAMStack Kings

Both solutions are following the JAMStack architecture we mentioned before.

By reading the official source, you can learn that JAMStack allows you to get:

  • Much better performance,
  • higher security,
  • cheaper na easier scaling,
  • better developer experience.

Simplifying and speeding up web development

Both tools are providing a boilerplate – a fixed project structure that needs to be followed during the development.

Having a boilerplate has many great advantages. For example:

  • Better documentation,
  • better tooling,
  • easier setup,
  • better development experience,
  • easier project handover.

Thanks to that, both Gatsby and Next can significantly simplify and speed up the React app/website development cycle.

A choice of big players

Both tools are used by big players who care about technology and are future proof professionals.

Next.jsGatsby.js
Mobile version of Twitch,
Netflix Jobs website,
Hulu,
IGN,
TikTok,
InVision.
Airbnb Engineering,
Impossible Foods,
Braun Canda,
Figma,
SendGrid,
Nike.

Source: https://start-up.house/en/blog/articles/gatsby-or-next


Hesitate to chose between Gatsby.js and Next.js?


Differences between Next.JS & Gatsby

SSG vs SSG + SSR

Gatsby JS is a static site generator (SSG), this is the only way it’s working.

Next.js initially was a server-side rendering tool, but since version 9.3 it also supports SSG.

Data handling

In this case, Next.js is much more flexible, as he enables developers to decide themselves how to approach data fetching.

Gatsby, on the other hand, enables you to use GraphQL only. It gives a solid standard of handling data but for some small projects it can be an overkill.

Community

JAMStack websites took web development by storm. So did Gatsby.

Developers immediately picked it up and fell in love, as it was extremely pleasant to work with. On top of that, it also became one of the hottest technologies in 2019.

People behind Gatsby itself are also working hard to engage their community. They run an interesting agency program to support companies that are doing JAMstack projects powered with Gatsby.

More than that, if you look at the Gatsby showcase, it is very big (1101 today) in comparison with the Next showcase (around 100 today).

Plugins, themes, extensions, integrations

Gatsby.js enables you to use many plug-ins, which can make your life a bit easier.

On the other hand, Next.js is encouraging you to build everything by yourself, which gives you pretty much unlimited possibilities and freedom in the execution. It means Next is better for ultra customized projects.


Real-world use cases of Gatsby.js

The great source of Gatsby website examples is Gatsby Showcase but to have a full picture of Gatsby features let me present you a few other examples.

Corporate websites (companies, service websites, marketing info sites)

Corporate websites are like digital business cards. They need to work super fast and are not updated very frequently.

These kinds of websites are displaying the same information for anyone visiting the site (no login & register functionalities, just plain information).

So, a corporate website requirements will be:

  • Great user experience (preloading)
  • Great performance (Google Page Speed)
  • Full SEO support (HTML output)
  • Integration with (headless) CMS

As Gatsby SSG performance is better than Next JS SSR & SSG, Gatsby is the winner there.

Corporate websites should be managed by CMS and this is also why Gatsby wins over Next, as it offers support for plugins to get content from almost all CMSs, databases, REST APIs, and GraphQL.

In summary, Gatsby wins because of:

  • Better performance than Next JS
  • Shorter development time with a wide range of Gatsby plugins, starters, themes and integrations with headless CMSes

Examples of super fast corporate websites built in Gatsby:

Digital Ocean

AutoloadIT

JIMDO


Public pages for any B2B or SaaS product websites

The main goal of B2B and SaaS websites is to convert visitors into customers.

This is where speed and user experience are both extremely important factors.

When you have calculated the cost of your lead you are now able to estimate and calculate ROI of a faster website (with lower bounce rate and higher organic search traffic).

B2B and SaaS product website requirements:

  • Great User Experience & Performance
  • Full SEO support
  • Integrations with user analytics, and automation marketing tools
  • Integrations with CRM

And once again, the winner here is Gatsby.js, mostly because of:

  • Better performance than Next JS
  • Shorter development time with a wide range of Gatsby plugins, starters, themes and integrations with headless CMSes

Examples of B2B and SaaS product pages built with Gatsby.js:

SendGrid

HASURA

JIMDO


Individuals’ blog websites

As an individual you want to have a blog that is:

  • Cheap to host
  • Easy to Edit
  • Advanced in technologies

Any static generated website is cheap to host, as you can host it for free using:

  • GitHub Pages
  • Netlify
  • Vercel

One of the most important things in having a blog is to be extremely SEO efficient, and obviously, it’s great to save cost on hosting, and this is why Gatsby is a winner here.

Examples of Individuals blog websites:

Kent C. Dodds

Most Recommended Books

Jacob D. Castro


Digital Agency Websites

Agency websites need to shine and prove that you (as an agency) put a lot of attention in every project, also internal, like your own company website.

So, most important requirements for a Digital Agency website could be:

  • Advanced technologically
  • Super performant
  • Covering all aspects of Usability, Accessibility and SEO

Thanks to Gatsby, you are able to present your website’s performance, SEO efficiency, as well as a pleasant user experience, and this is why Gatsby is a winner in this case.

Examples:

Roboto Studio

Made With Love

Third And Grove


Small eCommerce Websites

Gatsby works really well as a tool to build customized and static storefront for headless eCommerce.

It’s often integrated with Shopify, as it doesn’t give too many possibilities for customization.

In this scenario Gatsby is a storefront where visitors can browse the products and add them to the cart in a blink of an eye.

However, the checkout page is served by traditional eCommerce platforms like Shopify, and that makes Gatsby a great partner for Shopify.

Examples:

Curology

OTAKUCHAN

Nike


Best use cases for Next JS

Next also has its own showcase, and we highly recommend using it as a source of inspiration.

Generally, NextJS is a better idea to choose when SSR becomes more important than SSG.

This is when:

  • Content is frequently updated or needs to be always up-to-date
  • You have a large, multi-user site like TikTok (real-time publishing)
  • You can’t afford to rebuild the whole website (f.e. big eCommerce), as it would take ages to do it with SSG.

Lage multi-user websites

For large multi-user platforms and the amount of data generated by its users in real-time, it’s not a surprise that the crucial and absolutely most important thing is performance.

On top of that, “real-time” means rendering needs to be done constantly, with the newest data available.

This could be quite a challenge for Gatsby. And this is why in case of large multi-user websites, Next.js is the ultimate winner.

Examples of Large multi-user websites:

TikTok

Hashnode

Twitch mobile


Client-side rendered applications (SPA/MPA)

SPA is a web application or website that interacts with the web browser by dynamically rewriting the current web page with new data from the web server, instead of the default method of the browser loading entire new pages.

The goal is faster transitions that make the website feel more like a native app.

Top Single Page Application requirements should be:

SPA is a perfect solution to build an exceptional and rich interaction between the user and your application.

  • Super performant
  • Ability to support feature rich apps
  • Great user experience

Examples of SPAs built with Next.js:

hulu

Binance

Ticket Master


Big eCommerce Websites

Conversion is crucial for eCommerce platforms, as the ultimately successful user path should end up with a sale.

Besides that, if a small change will come, it needs to be visible everywhere, therefore, the production of SSG pages would take ages in that case.

For Big eCommerce, the most important factors are:

  • Speed
  • Custom user experience
  • Ability to make frequent changes
  • Integrations with third-party systems like: PIM, marketing automation, ERP.

Examples:

Deliveroo

JET

Ticket Swap


Web portals

The success of a web portal is mostly dependent on his performance, as a huge amount of data is constantly added in real-life time by it’s users (user generated content).

The other important factor for web portals is personalization and security.

Take a medical portal with a fragile health data of thousands of patients. You need to have something extremely safe and in many cases encoded & decoded in real time.

We could say that the most important factors for web portals are:

  • Super performant
  • Secure
  • Able to support custom features
  • Full support for real-time user generated content

And this is why Next.js is the winner in this case, as it would be incredibly hard to interact with users just by using static pages. Of course most of these functionalities you can achieve in Gatsby using third party services, but without them Next is a clear winner.

Examples:

Ticket Master

Realtor

TV Publica


The verdict?

Obviously, the verdict is highly dependent on what you are aiming for.

If the goal is to have a super fast website that doesn’t need much updates, then Gatsby.js is a no-brainer here.

Yet, if you want to have a superfast and user-friendly page that does need constant updates, definitely you should consider Next.js.

Comments
Leave a Reply

View Comments (0)...

Related articles:

Custom Shopify Storefront: How to Build One?

How to Make Shopify Store Faster?