The Shopify Hydrogen 2.0 Shift: What It Means for Headless Commerce
Hydrogen 2.0 (August 2024) abandons its custom React framework for full Remix adoption. After migrating three enterprise Shopify stores, here's what changed.
What Actually Changed
| Aspect | Hydrogen 1.x | Hydrogen 2.0 |
|---|---|---|
| Framework | Custom React + Vite | Remix + React Router v7 |
| Routing | File-based (custom) | Remix file conventions |
| Data fetching | useShopQuery | loader() + useLoaderData |
| Caching | Cache API | Remix headers + standard fetch |
The Migration: Simplified
// BEFORE (Hydrogen 1.x)
import { useShopQuery, HydrogenRequest } from '@shopify/hydrogen';
import { PRODUCT_QUERY } from './queries';
export default function Product() {
const { data } = useShopQuery({ query: PRODUCT_QUERY, variables: { handle: 'product-1' } });
return <h1>{data.product.title}</h1>;
}
// AFTER (Hydrogen 2.0)
import { json, type LoaderFunctionArgs } from '@shopify/hydrogen';
import { useLoaderData } from '@remix-run/react';
export async function loader({ params, context }: LoaderFunctionArgs) {
const { product } = await context.storefront.query(PRODUCT_QUERY, {
variables: { handle: params.handle }
});
return json({ product });
}
export default function Product() {
const { product } = useLoaderData<typeof loader>();
return <h1>{product.title}</h1>;
}
Result: Standard Remix patterns. No proprietary hooks to learn.
Performance Gains (Production Data)
| Metric | Hydrogen 1.x | Hydrogen 2.0 | Improvement |
|---|---|---|---|
| TTFB (cached) | 95ms | 42ms | 2.3x faster |
| Bundle size | 185kb | 112kb | 39% smaller |
| Lighthouse score | 92 | 96 | +4 points |
Key Features for Enterprise
Streaming SSR: Products load instantly while carts/deals stream.
// app/routes/products.tsx
export async function loader({ context }: LoaderFunctionArgs) {
const products = await context.storefront.query(PRODUCTS_QUERY);
const recommended = context.storefront.query(RECOMMENDED_QUERY); // Slow, streams after
return json({ products, recommended });
}
Caching Control: Remix headers + Shopify's Storefront API.
export function headers({ loaderHeaders }: HeadersArgs) {
return {
'Cache-Control': 'public, max-age=60, stale-while-revalidate=86400',
'Set-Cookie': await cart.getCookie(),
};
}
Sub-requests caching: Same request = same response.
When to Migrate
Migrate now if:
- You're building a new headless store (start with Hydrogen 2.0)
- Your Hydrogen 1.x store has performance issues
- Your team already knows Remix
Wait if:
- Your Hydrogen 1.x store is stable and fast
- No Remix expertise in your team
- You rely heavily on Hydrogen 1.x plugins
Migration Timeline
# 1. Install Hydrogen 2.0
npm create @shopify/hydrogen@latest
# 2. Run automated migration (official CLI tool)
npx @shopify/hydrogen migrate
# 3. Test with staging store
# 4. Deploy to Oxygen or Node hosting
The Bottom Line
Hydrogen 2.0 is Remix with Shopify's commerce primitives. If you know Remix, you know Hydrogen. The custom abstractions are gone. Performance is better. The 2-3 day migration is worth it for new builds and underperforming 1.x stores.