Skip to content

News

Astro 6 Is Coming: What It Means for Your Velocity Project

Astro 6 brings a rebuilt dev server, built-in CSP, Zod 4 and a Node 22 floor. Velocity already runs on the betas. Here's what changes and what we've done about it.

News No. 05

Velocity was built on Astro 6 from the start, while Astro 6 is still in beta. That gets you the new APIs early. It also means every beta can change something under you.

The first Astro 6 beta shipped on January 13th, and the stable release is getting close. This post covers what Astro 6 changes and what we’ve already changed in Velocity because of it, so you know what to expect when stable lands.

If you’re new here, Introducing Velocity covers what’s in the starter.

Where Velocity is today

Velocity launched on astro@6.0.0-beta.5. On February 8th we moved to 6.0.0-beta.9 and updated the @astrojs/mdx beta to match. That work shipped in v0.2.0-beta yesterday, and two CSP follow-ups are in v0.3.0-beta, tagged today. Most of what follows came out of that upgrade.

What Astro 6 changes

One runtime for dev and production

Until now, astro dev and your production build ran through different code paths, so some bugs only showed up after you deployed. Astro 6 rebuilds the dev server on Vite’s Environment API, so your code runs in the same runtime locally as in production.

On Cloudflare, that runtime is workerd, the engine behind Cloudflare Workers, so you get local access to bindings like KV and R2 without mocks. The old Astro.locals.runtime API is gone. Velocity doesn’t use it, so there’s nothing to change.

CSP, built in

Content Security Policy is now a config option, under security.csp. Astro hashes your scripts and styles and writes the policy for you.

Live content collections are stable

Regular content collections load at build time. Live collections, which were experimental, fetch at request time and keep the same schema validation. They’re useful for data that changes between deploys, like stock levels or prices from a CMS. Velocity’s collections are local Markdown and JSON, so they stay as they are.

The breaking changes, checked against Velocity

The Astro 6 upgrade guide lists every breaking change. Here’s how the ones that matter most apply to a Velocity project:

Astro 6 changeIn Velocity
Zod 4 replaces Zod 3Done. The standalone zod dependency is gone and the API routes import from astro/zod.
Astro.glob() removedNot used. Collections use the Content Layer glob() loader.
<ViewTransitions /> replaced by <ClientRouter />Not used. Velocity relies on prefetch, not the client router.
Node 22.12.0 or laterAlready required in engines.
CommonJS config files removedNot affected. The config is astro.config.mjs.
Vite 7Velocity’s only Vite plugin is @tailwindcss/vite.

Zod 4 in practice

Simple schemas like z.string() and z.object() keep working. The changes are at the edges. z.string().email() becomes z.email(), custom error messages use a new syntax, and .default() is stricter about types.

In Velocity, the visible change was in the contact and newsletter API routes. Zod 4 renames ZodError.errors to ZodError.issues, so both routes now read validation errors from result.error.issues.

If you added your own schemas, import z from astro/zod rather than installing zod yourself. That keeps you on the same version Astro uses.

Two smaller ones to check

Astro 6 changes how markdown heading IDs are generated, so links to #anchors in existing posts may break. And the default for i18n.routing.redirectToDefaultLocale has changed. If you generated your project with --i18n, check your routing after upgrading.

What we changed in Velocity

The Astro 6 upgrade was also a chance to use what it adds. All of this is in v0.2.0-beta:

  • CSP is on. security.csp is enabled, with explicit allowlists for Google Analytics and Google Tag Manager, so the optional analytics still load.
  • Type-safe environment variables. astro:env defines a schema for SITE_URL, the analytics IDs, verification codes, the contact form endpoint and the newsletter API key. Components import them from astro:env/server or astro:env/client instead of reading import.meta.env.
  • No more astro-seo. The SEO component now renders its own meta tags: title, description, canonical, robots, Open Graph, Twitter cards and verification tags. Its props didn’t change, so pages that use it don’t either.
  • One less experimental flag. experimental.contentIntellisense is no longer needed.

What CSP broke

Turning on CSP found two problems that a normal build didn’t show. Both fixes are in v0.3.0-beta.

The fonts loaded from Google Fonts through an inline onload handler, which CSP blocks. Velocity now self-hosts Manrope, Outfit and JetBrains Mono through Fontsource, so there are no external font requests at all.

The tab panels were hidden with an inline style="display: none", which CSP also blocks, so every panel showed at once until the page hydrated. They now use the hidden attribute.

If you add your own components, the same rules apply: no inline event handlers, and no inline styles for things that must work before JavaScript runs.

Upgrading your project

create-velocity-astro now has an upgrade command. It replaces the files Velocity owns, merges dependency updates into your package.json, leaves your pages, content and site config alone, and lists any manual steps:

pnpm create velocity-astro upgrade --dry-run
pnpm create velocity-astro upgrade

It needs a project created with CLI v1.6.0 or later, which writes the .velocity.json file the upgrade reads. For older projects, compare against the repo by hand.

Try it

Start a new project on the Astro 6 beta:

npm create velocity-astro@latest my-site

When Astro 6 is stable, we’ll move Velocity to it and note any changes in the release. For the wider picture, including Cloudflare’s acquisition of the Astro team, read Astro 6 Is Coming on the Southwell Media blog.

All posts
Share:

Related posts