Why I migrated my personal blog from Gatsby to Next.jsWhy I migrated my personal blog from Gatsby to Next.js

Why I migrated my personal blog from Gatsby to Next.js

For a long time, my technical blog was built and operated using “Gatsby,” but I recently made a complete transition to “Next.js (App Router).” Gatsby was a great static site generator (SSG), but why did you decide to migrate to it? I will share the reasons for this and the advantages and disadvantages I felt after actually making the transition.

Reason for deciding to migrate from Gatsby

1. GraphQL learning and management costs

Gatsby’s biggest feature is that it uses GraphQL for data fetching. It’s powerful to be able to retrieve data from Markdown files and external CMSs using a unified interface, but for small blogs, I’ve started to feel the overhead of having to write a GraphQL query even if I just want to retrieve some data.

2. Increased build time

As the number of articles increased, Gatsby’s build time gradually became longer. As is the fate of a full SSG architecture, the wait time between deployment and publication was several minutes long, which slowly detracted from the writing experience.

3. The charm of Next.js (App Router)

With the advent of Next.js’ App Router (React Server Components), it has become very simple to write the process of reading Markdown by directly hitting the file system (fs module) on the server side. I was attracted to the ease of being able to retrieve data using just plain asynchronous functions without using an intermediate layer like GraphQL.

Migration process and benefits gained

The main steps in the migration work were selecting a Markdown parser (introducing `remark` / `rehype`, etc.)'' and departing from Gatsby’s proprietary API.''

Benefit 1: Significantly simplified codebase

Complex configuration files such as gatsby-node.js are no longer needed, and article pages can now be generated using only Next.js’ dynamic routing ([slug]/page.tsx). The overall amount of code has been reduced and maintainability has been dramatically improved.

Benefit 2: Improved performance and flexibility

With Next.js, you can easily combine not only SSG (Static Site Generation) but also ISR (Incremental Static Regeneration). The build time has been significantly reduced and the Lighthouse score has maintained a perfect score.

Disadvantages and challenges

If I had to point out a disadvantage, it would be the richness of the plugin ecosystem. Gatsby has a wide range of functions necessary for blogs such as image optimization'', SEO meta tags’’, and ``sitemap generation’’ as an official plugin. With Next.js, you need to implement these yourself or build them by combining third-party libraries (such as next-sitemap).

Summary

Migrating from Gatsby took some effort, but the result was less of a black box and a blogging system that I had complete control over. It was also a great opportunity to experience the power of React Server Components, and I highly recommend moving to Next.js if you’re looking to modernize your technology stack.