Why I Moved from Astro to Next.js, Then Went Static Again

Published on
8 min read.
Tags: Next.jsDevOps

I moved henggana.com from Astro to Next.js in September 2025 for one reason. I wanted it to be easy to switch to server-side rendering whenever the site needed it. Astro can do SSR, but I think Next.js does it better.

Five months later that reason got tested in the other direction. The site ran SSR on a VPS until February 2026, when the VM went away to cut costs and a fully static export on Cloudflare took its place. The site never went offline. The plan landed in the repo on a Saturday night, and by 08:42 the next morning the Cloudflare config was committed.

Quick answer

What the git history shows:

  • The same Next.js App Router code ran as a Node server (output: 'standalone') and as plain HTML files (output: 'export'). Switching took three lines of config and a new data layer, done in one morning.
  • Rebuilding what Astro already did (RSS, sitemap, OG images, reading time, the design) took about two weeks of September commits.
  • Static export dropped things that took months to bring back: the 301 redirects in middleware and the RSS feeds.

Would I pick Next.js again? Maybe yes, if I'd already decided on Next.js. I like having one thing to maintain. But AI changed how I choose: now I pick whatever is faster to build and ship, and for me that isn't Next.js.

The Astro site

The Astro version started in October 2024 from Astro's blog template and was fully static: Astro 4.16 with the MDX, sitemap and RSS integrations, 16 posts as a content collection with a Zod schema, Sakura CSS on top of normalize.css, OG images from Satori, and reading time from a small remark plugin.

The config fit on one screen:

// astro.config.mjs
export default defineConfig({
  site: 'https://henggana.com',
  integrations: [mdx(), sitemap()],
  markdown: {
    remarkPlugins: [remarkReadingTime],
    shikiConfig: {
      theme: 'catppuccin-latte',
    },
  },
});

It ran on a DigitalOcean droplet for about $6 a month.

Why Next.js and not Astro SSR

Astro has an SSR mode. You set output: 'server' (or render single pages on demand) and add an adapter such as @astrojs/node. So the choice was about how well each framework does SSR.

The server-rendered part I had back then was htmx. I was trying it out on the Astro site, and it was awful. htmx swaps in HTML fragments the server renders, so I kept switching between writing HTML in .astro files and in .jsx files, and the partial rendering made that context switch worse. All of that for little gain.

I went with Next.js and the T3 stack instead: Prisma, tRPC and an auth library, with server components calling the database. Everything is JSX, in one place.

The migration, September 2025

I ran create-t3-app next to the Astro app in the same pnpm workspace, so both sites could build side by side. The Astro app stayed in the repo until May 2026.

The first goal was visual parity. The Sakura styles were rebuilt as Tailwind tokens with the exact measurements: 55em body width, #1d7484 as the primary color, a 1.618 line-height, and the same two mobile breakpoints at 684px and 382px.

Then a migration script read the Astro markdown files and inserted them into PostgreSQL. Posts and tags got tRPC routers. RSS, the sitemap, robots.txt, reading time and OG images each came back as a Next.js route. In Astro each of those was one line of config or one file in src/pages/. In Next.js each one was its own commit.

The five interactive JavaScript examples in one post were .astro components. They became React components rendered through next-mdx-remote.

Running SSR on a droplet

The SSR site ran on a DigitalOcean droplet with 2 vCPU and 2 GB of RAM, deployed with Kamal: Next.js in standalone mode, PostgreSQL 16, Redis 7, and later imgproxy for photo resizing.

The first deploy day, September 19, took 22 commits, most of them on the Docker image. Tailwind 4 uses lightningcss, which ships a native binary, and the Alpine (musl) image kept loading the wrong one. The commits go Alpine, then Debian, then back to Alpine with a lightningcss rebuild.

If you build Next.js in Docker, the other fix from that day applies to you too. sitemap.ts queried the database, so next build tried to connect to PostgreSQL inside the image build. Rendering the sitemap per request instead of at build time fixed it:

// src/app/sitemap.ts
export const dynamic = 'force-dynamic';

With a server available, the site grew fast. Over the next two months it got utility tools, Better Auth, an admin dashboard, en/id translations with next-intl, a photo gallery with uploads and color extraction, and a transit route finder that ran A* over GTFS data. Most of that needed the server.

The server needed attention too. In November 2025 there was a plan to move to a 1 vCPU droplet to save about $6 a month, and in December a commit turned off build-time type checking and the webpack cache to cut build memory.

Going static overnight

On February 9, 2026, the CI deploy trigger was turned off. On February 21 a three-phase plan landed in the repo: replace the VM with a static export at zero hosting cost, move SSR to Supabase and Vercel later, and return to a VM only when ad income or traffic justified it.

The switch landed the next morning, with the first commits at 07:21 Jakarta time and the Cloudflare config at 08:42. In next.config.js it was three added lines:

 const config = {
-  output: 'standalone',
+  output: 'export',
+  trailingSlash: true,
   images: {
+    unoptimized: true,
     remotePatterns: [

Most of the work was the data. Every page that called Prisma or tRPC on the server had to read build-time data instead. A script dumped the database to JSON files under data/, and a thin data layer in src/lib/data/ exposed the functions the pages needed:

// src/lib/data/posts.ts (February 2026)
// Data Abstraction Layer — Phase 1 static build
// Phase 2: swap this file's implementation back to Prisma; page components stay unchanged.
const rawPosts = require('../../../../../data/posts.json') as any[]

Pages stopped importing db and api and imported from ~/lib/data/* instead. Dynamic routes got generateStaticParams. The main commit touched 53 files, and the one for the photo pages deleted about 1,500 lines and added 430, mostly swapping Prisma queries and pagination for array filters.

None of that was a rewrite. The components, the i18n routing and the route structure carried over, and the plan for going back to SSR is the same swap in reverse.

What took months to restore

next build with output: 'export' fails loudly on some things, like a dynamic route without generateStaticParams. Server features with no static equivalent are your job to replace, and two of them stayed missing for months.

301 redirects. The legacy redirects (/blog to /en/blog/, /tags, /about, /contact and the old tool URLs) lived in middleware.ts, renamed proxy.ts in the same commit. A static export has no server to run it. The switch replaced / and /tools with client-side redirects, but the other paths had none, and nothing was a real 301. The 301s came back on October 9, 2026, as a Cloudflare _redirects file:

# Root and pre-i18n URLs (the old middleware redirects; it doesn't run on a static export)
/ /en/ 301
/blog /en/blog/ 301
/blog/ /en/blog/ 301
/blog/:slug /en/blog/:slug/ 301

If your middleware does redirects, move them to your host's redirect rules (_redirects on Cloudflare or Netlify) in the same change that turns on output: 'export'.

RSS feeds. /rss.xml and /photos/rss.xml were route handlers that queried Prisma, and the switch deleted them. They came back, built from the static data, in the same October fix. Both were 404 for over seven months.

Two other losses were planned:

  • Query-string pagination. The photo pages read ?page= from searchParams on the server. A static export can't do that, so pagination went away.
  • Image optimization. images.unoptimized: true is required with the default loader. Thirteen days later the image component became a plain <img> with a hand-built srcset pointing at Cloudflare Image Resizing, which replaced imgproxy.

The dashboard, auth, uploads and the transit finder no longer work at runtime. Their code is still in the repo for when SSR comes back.

The posts ended up back in markdown

The static export doc from that February weekend said not to store posts as markdown files, because JSON would be easier to import back into PostgreSQL.

On May 23, 2026, the posts moved from data/posts.json to one folder per post (content/posts/<slug>/ with meta.json, en.md and id.md), and the Astro app was deleted the same day. Going back to PostgreSQL now needs an import script again. In exchange, a post is a folder you edit and review in git, which is how the Astro site kept them.

TL;DR

henggana.com moved from Astro to Next.js to keep the SSR option open, ran SSR for five months, and went back to output: 'export' in one morning. Before you flip to a static export, list every middleware redirect and route handler, and replace each one in the same change.