Back to field notesPlatform & DevOps

We moved our React site to Astro and cut blog JavaScript by 77%

Our site was a Vite and React Router single-page app. We rebuilt it on Astro in one branch, kept the React homepage as an island, and stopped shipping React to the blog at all. Here is what we measured, what broke, and when we would tell another team to do the same.

Every page on our site used to download the same 190 KB of compressed JavaScript before it showed anything real. That included this blog, where the only moving part is the sky behind the text.

We moved the site to Astro last week. Blog pages now load 43.6 KB of JavaScript, and none of it is React. The homepage still runs React, because its animations are worth it, and it loads 40% less than before. Search engines and AI crawlers now read the same HTML that people see.

This post covers why we moved, how Astro made it possible without rewriting our components, what broke along the way, and how to tell whether your own site is a good fit.

Before and after the Astro migration
77%Less JavaScript on blog pages190.4 KB down to 43.6 KB, gzip, per page load
40%Less JavaScript on the homepage190.4 KB down to 114.0 KB, still two React islands
6.3xMore homepage text without JavaScript874 words of the real page, up from a 139-word noscript summary
-337Net lines of code437 added, 774 removed, excluding the lockfile and tests
OpenSkye measurements of the builds before and after merge commit 2c346ec, taken on 2026-11-06. Method and caveats are in the source pack.

What was wrong with our React single-page app

The site started as a standard Vite and React app. One index.html file held an empty <div id="root">. React Router decided which page to draw, and one JavaScript bundle carried the code for all of them.

That setup works well for an app people log into. For a marketing site and a blog, it had three costs.

Every page paid for the homepage. The bundle held React, React Router, GSAP and all the homepage code. A reader opening an article downloaded 538 KB of raw JavaScript, 190 KB compressed, to read text that does not change.

Crawlers saw a copy, not the page. A page that only exists after JavaScript runs is a problem for search and for AI crawlers that do not run scripts. We worked around it with a 301-line build script, finalize-dist.mjs. After Vite finished, it copied index.html once per route, used regular expressions to strip and re-insert the title, meta and canonical tags, and wrote a <noscript> summary of each page. For the homepage, that summary was 139 words and 3 links. People saw one page, and crawlers without JavaScript saw a different, hand-maintained one.

SEO logic lived in two places. The build script wrote tags for crawlers, and a React hook, usePageSeo.js, rewrote them in the browser after each route change. A change to how we build a title had to land in both, and nothing failed when they drifted apart.

What Astro does differently

Astro is a web framework built for content-driven sites like blogs, marketing pages and stores. By default it renders every component to HTML and CSS at build time and removes the client-side JavaScript.

You opt back into JavaScript one component at a time. Astro calls such a component an island. The term “component island” comes from Etsy frontend architect Katie Sylor-Miller in 2019, according to Astro’s docs. Each island gets a client:* directive that says when its code should load.

There are five directives:

  • client:load loads and hydrates the component as soon as the page loads.
  • client:idle waits until the page has finished its initial load.
  • client:visible waits until the component scrolls into the viewport.
  • client:media waits until a CSS media query matches.
  • client:only skips server rendering and renders only in the browser.

The part that made our move cheap is that islands can be React, Preact, Svelte, Vue, Solid or web components. We did not have to rewrite anything to start.

Two request flows for /blog. Before, the browser gets a copied index.html with meta tags and a noscript summary, downloads a 190 KB JavaScript bundle, and only then does React draw the page. After, Astro sends the full HTML page, then 44 KB of GSAP animates the sky.
The same request before and after the move. The old page became readable only after the whole bundle ran. The new page is readable when the HTML arrives. OpenSkye Labs build measurements, November 2026

We kept React for the homepage

Our homepage is one long animated scene. An airship loader plays on the first visit, the sky moves from noon to night as you scroll, and the mascots react to the page. The homepage component alone compiles to about 30 KB of JavaScript, and it works. Rewriting it was out of scope from day one.

So the whole homepage became a single React island. The Astro page around it is short. This is a trimmed version:

---
import Base from '../layouts/Base.astro';
import SkyLoader from '../components/SkyLoader.jsx';
import Home from '../views/Home.jsx';
import { getAllPosts } from '../lib/content/loadPosts';
import { buildHomeSeo } from '../lib/seo/siteSeo';

const latestPosts = getAllPosts().slice(0, 3);
---

<Base seo={buildHomeSeo(latestPosts)}>
  <SkyLoader client:load />
  <Home client:load posts={latestPosts} />
</Base>

Astro renders Home to HTML at build time, so the first response already holds all 874 words of the page. React then hydrates that markup in the browser and the animations start.

The blog went further. BlogList.jsx and BlogPost.jsx are still React components, but their pages render them with no client:* directive. Astro runs them once at build time and ships plain HTML. The only script on a blog page is a 6-line Astro component that starts the GSAP scroll animation for the sky. That is the whole difference between 190 KB and 43.6 KB.

What we measured

We built the site at the commit before the merge and at the merge commit, served each build locally, and loaded three pages in headless Chrome. We recorded every script each page requested and compressed those files with gzip to get the size a visitor downloads.

JavaScript per page load, gzip KB

The old site sent one bundle to every page. Astro sends each page only the islands and scripts it uses.

Homepage, before190.4
React, React Router, GSAP, all pages
Homepage, after114.0
SkyLoader and Home islands with GSAP
Blog index, before190.4
same bundle as the homepage
Blog index, after43.6
GSAP for the sky, no React
Article, before190.4
same bundle as the homepage
Article, after43.6
GSAP for the sky, no React
OpenSkye measurement, 2026-11-06. Script files requested in headless Chrome, compressed locally with gzip level 9.

Then we loaded the same pages with JavaScript turned off. That is roughly what a crawler that does not run scripts receives.

Words visible with JavaScript turned off

The old homepage showed a short noscript summary. The new one shows the real page.

Homepage, before139
noscript summary, 3 links
Homepage, after874
the full page, 16 links
Blog index, before208
noscript list, 5 links
Blog index, after266
the full page, 13 links
Article, before1308
noscript copy of the article, 3 links
Article, after1479
article plus related posts and navigation, 15 links
OpenSkye measurement, 2026-11-06. Word count of document.body.innerText and count of links in headless Chrome with JavaScript disabled.

Two numbers did not move. Both builds take about one second on our machine, so build speed was not a reason to switch. We also have not collected Lighthouse or field Core Web Vitals data yet, so we are not claiming a speed score or a ranking change. Astro’s own site says an Astro site can load 40% faster with 90% less JavaScript than the same site on the most popular React framework. That is Astro’s claim, and our numbers only show the JavaScript half of it.

What the move did for SEO

The biggest SEO change is that there is now one page, and everyone gets it.

  • Crawlers read the real HTML. Headings, article text, internal links and related posts are in the first response. With JavaScript off, the homepage went from 3 links to 16.
  • Tags come from one place. A shared Astro layout, Base.astro, writes the title, description, canonical URL, Open Graph tags and JSON-LD from one seo object per page. The regex script and the React hook are both gone.
  • Nothing rewrites the head in the browser. The tags a crawler reads at build time are the tags the page keeps.
  • Every URL stayed the same. /, /blog and each /blog/<slug> kept their paths, and unknown paths still return a real 404 status with the “This note flew away” page.

The RSS feed, sitemap and llms.txt files still come from the same generator script as before. We left them alone on purpose, because they already worked.

What broke on the way, and how we fixed it

The migration was one branch and four commits, but it was not free. These are the problems we hit. Most of them come from moving a page that used to render only in the browser to one that renders on the server first.

Image imports changed shape. In Vite, import cover from './cover.png' gives you a URL string. In Astro it gives you an image object, and SVGs become components. We added ?url to all 25 image imports so they kept returning strings.

The loader flashed before React loaded. Our airship intro plays once per browser session, and the code decided that in React by reading sessionStorage. With server HTML, the page painted before React could decide, so returning visitors saw the loader flash. The fix is a small inline script in <head> that reads sessionStorage before the first paint and puts a class on <html>. CSS then shows or hides the loader from that class.

React threw a hydration error. React’s error #418 means the HTML from the server does not match what React draws in the browser. Our loader rendered different markup depending on that session check. We changed it to render the same markup every time and to switch visibility with the class instead.

Animated text flashed on screen before GSAP hid it. Elements that rise into view start hidden. Hiding them with opacity: 0 in CSS broke the animation, because GSAP’s from() animates back to the element’s current opacity, which was now zero. We hide them with visibility: hidden until GSAP is ready, then remove the class.

Homepage load order after the move. An inline head script sets classes before the first paint. The server HTML paints with the loader shown and the rising elements hidden. The SkyLoader and Home islands hydrate onto matching markup. GSAP sets up its animations and removes the hiding class. An eight-second failsafe removes the classes if the islands fail to load.
The homepage first-paint sequence. The head script makes the decision React used to make, before anything is on screen. OpenSkye Labs

Our own failsafe cut the intro short. The head script also starts an 8-second timer that removes the loader class, so a failed script load cannot leave the page covered. In review we found that the timer fired in the middle of a slow intro. Now the loader component cancels the timer once it takes over.

Text lost contrast without JavaScript. The late sections of the homepage sit on the night sky, which a scroll animation paints in. With JavaScript off, that text sat on the daytime gradient at a contrast ratio of 2.00 to 1. Those sections now carry their own dark backdrop, and the backdrop turns off once the animated sky is live. A test in our suite checks this on every build.

Hash links needed their own scroll. Going from the blog to /#hello used to be a client-side route change. Now it is a full page load, so the homepage reads the hash after it mounts and scrolls to the section itself.

Vercel needed a newer Node. Astro 7 needs Node 22.23.4 or later. We set engines in package.json, and the Vercel preview build passed on the first try with no dashboard changes.

Should you move your site to Astro?

Astro is a good fit if most of your pages are content that is the same for every visitor:

  • a marketing site, a docs site, a blog or a store catalogue
  • a React or Vue single-page app that serves mostly static pages
  • a site where search or AI crawler visibility matters
  • a team that wants to keep its existing components and change the build around them

Keep your current setup if your product is mostly interactive app screens behind a login. A dashboard where every widget shares live state is easier to build as one client-side app. Astro islands do not share React context with each other. Astro recommends Nano Stores for shared state, which it says ship less than 1 KB with no dependencies, but that is still a design change for a heavily stateful app.

Astro also has a funded team behind it. In January 2026, Cloudflare announced that The Astro Technology Company had joined Cloudflare, and said it uses Astro itself. Astro says the framework stays open source, MIT licensed and platform-agnostic. Our site runs on Vercel, and its static Astro build needed no Vercel adapter.

How to start your own migration

This is the order that worked for us.

  1. Write tests against the old build first. We wrote acceptance tests for every URL, status code, canonical tag and JSON-LD block before changing any code, then made them pass on the new build.
  2. Wrap the existing app as one island. Mount your top-level component with client:load on an Astro page. That alone gives you server HTML.
  3. Move pages that do not need the browser off the client. Render them with no directive and check what JavaScript is left.
  4. Move SEO tags into a layout. Put the head tags in one Astro layout that takes the page’s data, and delete any code that rewrites them in the browser.
  5. Look for anything that reads browser state during render. window, localStorage, sessionStorage and media queries are the usual causes of flashes and hydration errors. Move those decisions to an inline head script or into effects.
  6. Compare screenshots of old and new. We diffed 8 page and width combinations. Most differed by 0.21% of pixels or less, and the largest, 1.30%, was one frame of a background video.

Our homepage is still one large island. The next step is to split it so sections like the crew cards load with client:visible instead of on page load. That should bring the homepage closer to the blog’s numbers.

FAQ

Can I use my React components in Astro?

Yes. Install the @astrojs/react integration and import .jsx or .tsx components into .astro pages. Without a client:* directive they render to HTML only. With one, they hydrate in the browser like a normal React app.

Do I need to rewrite my site to move to Astro?

No. We kept every React component we had. The homepage runs as a React island, and the blog components render at build time. The work was in the page shell, the SEO layout and fixing browser-only code that ran during render.

Does Astro work on Vercel?

Yes. Vercel built and served our static Astro output with our existing project settings. The only change was the Node version in package.json.

Is Astro good for SEO?

Astro sends complete HTML for every page, so crawlers that do not run JavaScript still see your content, headings and links. That is the main SEO benefit. Titles, descriptions and structured data still need the same care as on any other framework.

Sources

All field notes
Keep reading

More from the hangar.