Migrating my photography portfolio from NextJS to Astro

DesignDevelopmentQ1—2026
The photography portfolio homepage in a browser window

Introduction

Giving my photography portfolio a makeover with sleek animations and (significantly) smaller bundle.

Context

My old portfolio was due a redesign, but NextJS was actually working against it. Pages arrived empty until JavaScript ran, the new animations would bloat the bundle, and most of NextJS's offerings went unused on a site that only shows photos.

Problem solved

83% less JavaScript, a Lighthouse SEO score up from 83 to 100, and pages that arrive as real HTML instead of an empty shell.

An Empty Initial Render

The NextJS version looked fine once it loaded, but the problem was around that initial render.

The root layout utilised separate desktop and mobile trees with a useMediaQuery hook. A null value was returned until React had mounted, which caused zero content rendering on the server side (validated in-browser by disabling JavaScript, resulting in a metadata shell + client rendering instructions).

It’s important to clarify that this isn’t a shortcoming of NextJS. It is simply an app-first framework that I was using for a content-first site. I had the option of altering the next.config.ts file to export the site as static, but this would have added a lot more boilerplate and refactoring across the client component architecture and outputs.

Redesigning the Site

This exploration began because I wanted to redesign my site to be more interesting and playful. The plan was to include animations across a background grid along with cleaner image transitions.

Using the old stack of React, NextJS and motion/react would have made this relatively simple to build. The grid could exist as a client component managed by hooks like useEffect and useMotionValue. However, the hydration and build time for 40+ purely decorative assets would have led to a huge bundle size relative to other frameworks.

Why Astro Made Sense

Astro is a content-first framework that provides static HTML outputs, decoupling content from the interaction layer. Any additional JavaScript required is treated as an enhancement instead of a necessity.

I would be sacrificing the simplicity of lifecycle management with React, along with image storage in the form of Vercel Blob (integrated with NextJS). However, I chose to prioritise the easier mental model and smaller dependency surface provided by Astro.

Replacing Vercel Blob with an in-repo image store was also surprisingly more efficient:

Image Display Mechanism
NextJS
Astro
Build [Once per deploy]
Each visit
Nothing prepared ahead of time
HTML arrivesEmpty shell w/o <img> tags
JavaScript runsLayout + content rendered184 KB JS
Browser finds imageRequest made to the CDN
Image resizingFetched from Blob and resized1 MB original
Image on screen
Image resizing1MB → required width set
HTML arrivesPre-listed images w/ widths
Browser picks widthImage size selected instantly
Served as a static fileCached for a year w/ no additional generations
Image on screen
Avg. Download per Image
Mobile device Lighthouse test [Median of 3 runs]
  • 217 KBNextJS
  • 79 KBAstro
For the 40+ images my redesign required, I’ve saved about ~9MB in downloads by migrating.

TLDR

MetricNextJSAstro
JavaScript per page184 KB31 KB
Average photo download (gallery)217 KB79 KB
First photo requested103 ms30 ms
Lighthouse SEO83100
Lighthouse best practices96100
Dependencies236
Local builds of both versions, Lighthouse phone-sized test, median of three runs.

Takeaways

Sanity-check your SSR through the browser:

  1. Right-click, go to ‘View Page Source’ and search for the main sections to verify the actual server contents.
  2. Within the DevTools panel, disable JavaScript and reload the page.
  3. Inspect the initial document response in the Network tab.

If none of these render any content, your site is likely relying entirely on hydration.