Skip to content

Getting Started with Astro 5

2 min read

Astro has quietly become the most interesting framework in the front-end ecosystem. Not because it does everything — it doesn’t — but because it makes very deliberate trade-offs: ship less JavaScript by default, use any UI framework you want, and treat content as a first-class concern.

Version 5 doubled down on all of this.

What changed in Astro 5

Content Layer

The most significant change is the unified Content Layer. Content collections are no longer limited to local files — you can now pull from any source using a loader. The built-in glob loader handles local markdown and MDX, but the API is open:

import { defineCollection, z } from 'astro:content';
import { glob } from 'astro/loaders';

export const collections = {
  blog: defineCollection({
    loader: glob({ pattern: '**/*.{md,mdx}', base: './src/content/blog' }),
    schema: z.object({
      title: z.string(),
      pubDate: z.date(),
      tags: z.array(z.string()).default([]),
    }),
  }),
};

The content.config.ts file moves to src/content.config.ts (note: no content/ subdirectory). This trips people up on migration.

Server Islands

Astro 5 introduced Server Islands — components that opt into server rendering while the rest of the page stays static. This is different from full SSR: you get a static shell with selective hydration for dynamic parts.

---
import UserGreeting from '../components/UserGreeting.astro';
---

<UserGreeting server:defer>
  <span slot="fallback">Loading...</span>
</UserGreeting>

ViewTransitions → ClientRouter

The <ViewTransitions /> component was renamed to <ClientRouter />. The behaviour is the same — Astro handles page transitions using the View Transitions API with a JavaScript fallback.

import {ClientRouter} from 'astro:transitions';

<ClientRouter />

Should you migrate?

If you’re on Astro 4, yes — but read the migration guide carefully. The content collection changes are the main friction point. If you have custom loaders or complex collection configs, budget a few hours.

If you’re starting fresh, start on 5. The DX is noticeably better.

What I’m building with it

This site is built on Astro 5 with a few opinionated choices:

  • Static output only — no server components
  • Tailwind CSS v4 via the @tailwindcss/vite plugin (not @astrojs/tailwind)
  • Cloudflare Workers for deployment using the static assets approach

I’ll write more about each of these in future posts.