In the Astro vs Hydrogen decision for a headless Shopify store, choose Hydrogen when the storefront is an app: a large catalogue, rich cart and account features, and a React team that wants Shopify’s own tooling and hosting on Oxygen. Choose Astro when the store is content-led (a brand site, editorial pages, a modest catalogue) and you want the lightest pages, any host and the option to send buyers to Shopify’s hosted checkout. Both read from the same Shopify Storefront API.
Hydrogen is Shopify’s React-based framework for custom storefronts, built on React Router and deployed to Oxygen, Shopify’s hosting. Astro is a general web framework that renders HTML with no JavaScript by default and adds interactive islands where needed. Neither replaces Shopify itself: products, inventory, payments and checkout stay in Shopify either way.
Key Takeaways
- Hydrogen is commerce-specific: cart, customer accounts, analytics and caching helpers are built around the Storefront API.
- Astro is general-purpose: you call the Storefront API yourself and build cart behaviour as an island or server route.
- Hydrogen renders on the server for every request; Astro can pre-render product pages at build time and serve them from a CDN.
- Hydrogen ships React to the browser; Astro ships JavaScript only for interactive parts like the cart.
- For a small catalogue with strong content, Astro is often simpler. For a full custom shopping app, Hydrogen saves the most work.
Astro vs Hydrogen at a glance
| Astro | Shopify Hydrogen | |
|---|---|---|
| Scope | General web framework | Shopify storefront framework |
| UI library | Any (or none); React, Vue, Svelte as islands | React |
| Rendering | Static by default, on-demand per route | Server-rendered with streaming |
| Shopify data | Storefront API via fetch or a client |
Built-in Storefront API client and hooks |
| Cart | Build it, or redirect to Shopify checkout | Cart utilities and components included |
| Customer accounts | Build it with server routes | Customer Account API integration |
| Hosting | Any static or Node.js/serverless host | Oxygen (Shopify), or other hosts with setup |
| Client JavaScript | Only where client:* is used |
React runtime on every page |
| Best for | Content-led stores, brand sites, small catalogues | Large catalogues, app-like shopping |
How each one talks to Shopify
Both use the Storefront API, a GraphQL API exposed by your Shopify store. Hydrogen wraps it with a typed client, caching strategies and React hooks. In Astro you write a small helper:
// src/lib/shopify.ts
const endpoint = `https://${import.meta.env.SHOPIFY_STORE_DOMAIN}/api/2025-10/graphql.json`;
export async function shopify<T>(query: string, variables: Record<string, unknown> = {}): Promise<T> {
const res = await fetch(endpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Shopify-Storefront-Access-Token': import.meta.env.SHOPIFY_STOREFRONT_TOKEN,
},
body: JSON.stringify({ query, variables }),
});
const json = await res.json();
if (json.errors) throw new Error(json.errors[0].message);
return json.data as T;
}
Set the API version in the URL to a current supported version from Shopify’s docs. Get the token by creating a headless storefront in Shopify admin (the Headless sales channel).
Product pages: pre-rendered vs server-rendered
Hydrogen renders each product page on the server when it’s requested, with caching to avoid hitting the API every time. Prices and inventory are always fresh.
Astro can pre-render every product page at build time:
---
// src/pages/products/[handle].astro
import BaseLayout from '../../layouts/BaseLayout.astro';
import { shopify } from '../../lib/shopify';
type Product = {
handle: string;
title: string;
description: string;
featuredImage: { url: string; altText: string | null } | null;
priceRange: { minVariantPrice: { amount: string; currencyCode: string } };
variants: { nodes: { id: string }[] };
};
export async function getStaticPaths() {
const data = await shopify<{ products: { nodes: Product[] } }>(`{
products(first: 100) {
nodes {
handle title description
featuredImage { url altText }
priceRange { minVariantPrice { amount currencyCode } }
variants(first: 1) { nodes { id } }
}
}
}`);
return data.products.nodes.map((product) => ({ params: { handle: product.handle }, props: { product } }));
}
const { product } = Astro.props;
const price = product.priceRange.minVariantPrice;
---
<BaseLayout title={product.title} description={product.description.slice(0, 155)}>
{product.featuredImage && <img src={product.featuredImage.url} alt={product.featuredImage.altText ?? product.title} width="800" height="800" />}
<h1>{product.title}</h1>
<p>{price.amount} {price.currencyCode}</p>
<form method="post" action="/api/checkout/">
<input type="hidden" name="variantId" value={product.variants.nodes[0].id} />
<button type="submit">Buy now</button>
</form>
</BaseLayout>
Pre-rendered pages load from a CDN with no server work. The trade-off is freshness: price or stock changes need a rebuild (triggered by a Shopify webhook to your host’s deploy hook), or you mark price-sensitive routes for on-demand rendering. A server island is a good middle ground: the page stays static and only the price and stock block renders per request.
For catalogues with thousands of products and frequent changes, Hydrogen’s always-server approach avoids long rebuilds. That’s one of its clearest advantages.
Cart and checkout
Hydrogen includes cart handling: create a cart, add and update lines, persist it across visits, and hand off to Shopify checkout. It also integrates customer accounts.
In Astro you choose how much cart you need. The simplest path is “Buy now”: a server endpoint creates a cart and redirects to Shopify’s hosted checkout.
// src/pages/api/checkout.ts
import type { APIRoute } from 'astro';
import { shopify } from '../../lib/shopify';
export const prerender = false;
export const POST: APIRoute = async ({ request, redirect }) => {
const form = await request.formData();
const merchandiseId = String(form.get('variantId'));
const data = await shopify<{ cartCreate: { cart: { checkoutUrl: string } | null } }>(
`mutation ($lines: [CartLineInput!]!) {
cartCreate(input: { lines: $lines }) { cart { checkoutUrl } }
}`,
{ lines: [{ merchandiseId, quantity: 1 }] },
);
if (!data.cartCreate.cart) return new Response('Could not create cart', { status: 500 });
return redirect(data.cartCreate.cart.checkoutUrl, 303);
};
This route needs an adapter (Cloudflare, Netlify, Vercel or Node), while every other page stays static. A full multi-item cart is a client island (React, Svelte or vanilla JS) that stores the cart ID and calls the same API. It’s very doable, but it’s code Hydrogen gives you already. See which rendering mode to use for mixing static and server routes.
Performance and hosting
Hydrogen pages are server-rendered React with streaming, and the React runtime hydrates on the client. Shopify optimises Hydrogen on Oxygen, and performance is good, but every page carries the cost of a React app.
Astro product and content pages ship as HTML with no framework JavaScript. Only the cart island, if you add one, loads JavaScript. For stores where most visits are to content (lookbooks, guides, landing pages) and a few to product pages, that difference adds up.
On hosting, Hydrogen fits most naturally on Oxygen, which is part of Shopify. Astro deploys to any static host for pre-rendered pages, plus an adapter for the few server routes.
Choose Astro or Hydrogen
Choose Hydrogen if:
- The catalogue is large or changes constantly.
- You need a full custom cart, customer accounts and app-like interactions.
- Your team works in React and wants Shopify’s official framework.
- Hosting on Oxygen inside Shopify suits you.
Choose Astro if:
- The store is content-led: brand storytelling, editorial, a few dozen products.
- You want the lightest pages and static hosting on any CDN.
- “Buy now” to Shopify checkout, or a small cart island, is enough.
- The site also includes a blog, docs or marketing pages you want in one project.
Choose neither yet if: Shopify’s own themes cover your needs. Headless adds development cost; it pays off when the default storefront limits you.
For more ways to sell from an Astro site (Snipcart, Stripe links, Lemon Squeezy), see e-commerce options for Astro. If you’re building a shop front from scratch, the Retail & E-commerce category has Astro layouts with product listings and detail pages you can connect to the Storefront API.
FAQ
Can Astro work with Shopify?
Yes. Astro can fetch products from Shopify’s Storefront API at build time or per request, render product pages, and send buyers to Shopify’s hosted checkout. Products, payments and orders stay in Shopify.
Is Hydrogen better than Astro for headless Shopify?
For a full custom storefront with cart, accounts and a large catalogue, Hydrogen saves the most work because it’s built for exactly that. For content-led stores and small catalogues, Astro is often simpler and ships less JavaScript.
Does Hydrogen use Remix?
Hydrogen was originally built on Remix. Remix merged into React Router, and current Hydrogen versions are built on React Router. Check Shopify’s Hydrogen docs for the version your project uses.
Do I need a server to run a Shopify store on Astro?
Not for product pages, which can be pre-rendered. You need on-demand rendering (an adapter) only for routes that create carts or show live prices, or you can send buyers to Shopify checkout with links and avoid a server entirely.
Can I host Hydrogen somewhere other than Oxygen?
Yes, Hydrogen can be deployed to other JavaScript hosts, but Oxygen is the default and best-supported option. Astro has no preferred host and deploys to any static or serverless platform.