Astro
A framework for content sites: HTML at build time, JavaScript only in islands, content from a CMS.
Frontend
- Category
- Frontend
In practice
I mostly write in Next.js, but when a site lives on search traffic and mostly shows content, I reach for Astro with Payload CMS. That is how I treat business-card sites, portfolios and blogs. When accounts, bookings or heavy interactivity come in, I go back to Next.js.
What is Astro?
Astro is a framework for content-driven websites. By default it renders every page to HTML and CSS at build time and strips the JavaScript the page does not need. Interactive components are islands: separate pieces that load their code independently of the rest of the page.
A client directive turns a component into an island, for example client:visible, which loads it only in the viewport. React components run through an official integration and, with no directive, reach the browser as plain HTML.
- Rendering
- Static HTML, on demand through an adapter
- JavaScript
- Only in islands with a client directive
- Content
- Content collections with a Zod schema
- License
- MIT
How I work with Astro
I first ask how much of the site reacts to the visitor. If it is a contact form and a menu, no page needs a whole framework in the browser.
Content from Payload CMS
Payload runs as a separate app with the editor panel, and Astro reads the REST API that Payload generates from its collections. A content collection with a Zod schema describes the data, so a missing field fails the build, not the visit.
Islands only where needed
A gallery or a post filter I write in React and mark with
client:visible. The rest stays plain HTML, styled with Tailwind CSS, which Astro adds through its official Vite plugin.Static for as long as possible
I generate the whole site at build time. When one page must render per request, I add an adapter and turn prerendering off for that page alone. After launch I measure Core Web Vitals on the live site.
When it fits, and when it doesn't
I choose Astro where a site above all has to be found and read.
A good fit when
- A company business-card site meant to bring clients from Google.
- A portfolio with a gallery of work.
- A blog or guides site where an editor publishes from a CMS panel.
- A landing page where load time on a phone matters.
Not a fit when
- An app with user accounts, a client panel or bookings.
- An interface where most of the screen reacts to clicks.
- A project soon to grow into an app, with one framework wanted for all.
- A site the owner builds alone in a page builder, with no code.
A site mixing content with app logic is covered under Next.js, and visibility work for any framework sits in technical SEO.
Astro or Next.js?
Both give a search engine ready HTML. They differ in what reaches the browser and how much app logic they assume.
| Criterion | Astro | Next.js |
|---|---|---|
| JavaScript in the browser | None by default, only in islands | React runtime on every page |
| Components | .astro files plus React or Vue | React, server components by default |
| Default rendering | HTML generated at build time | Static or per request, in one app |
| Markdown and MDX | Markdown built in, MDX through an integration | MDX through the @next/mdx package |
| Application logic | Actions and on-demand pages through an adapter | Server Actions and route handlers built in |
| Typical project | A content site built for SEO | Content combined with application logic |
Astro, when the site is there to be read
When a site mostly shows content and lives on search traffic, I take Astro with Payload CMS. Few spots are interactive, so most pages need no JavaScript.
Next.js, when the site has to do things
When accounts, bookings or payments come in, I choose Next.js. The React runtime is needed then anyway, and one framework handles content and logic.
Frequently asked questions
A business card, a portfolio or a blog?
Tell me what the site should show and whether it does more than content: a form, accounts, bookings. I will say whether Astro with Payload CMS is enough or Next.js fits better from the start.