Headless Shopify with Hydrogen
Oxygen, Remix, and glass — how I shipped shopify-frost in a weekend.
Shopify themes are comfortable — until they are not. The moment you want a custom cart drawer, an animated hero, or a product page that does not look like every other store, Liquid starts fighting you. I wanted a storefront that felt like a design site, not a template. Headless was the only way.
Headless means Shopify stays as the commerce engine — products, inventory, checkout — and you own the entire frontend. The API is Storefront GraphQL, the hosting is Shopify Oxygen, and the framework is Hydrogen — which is just Remix tuned for commerce.
Why Hydrogen over Next.js + Storefront API?
I could have used Next.js with fetch to the Storefront API and been done. But Hydrogen gives you three things for free that you would rebuild anyway:
- Prebuilt commerce primitives —
<CartProvider>,<Money>,<Image>with Shopify CDN, variant selectors. - Oxygen runtime — edge workers with built-in Shopify auth, caching, and analytics. No VPC or edge config.
- Remix loaders/actions — server data loading that matches Shopify caching headers exactly, so
Cache-Controljust works.
The tradeoff is lock-in to Remix conventions. I took it gladly — the velocity was worth it.
The stack for shopify-frost
Hydrogen 2024.10 + React Router 7 (Remix) + Tailwind 4 + shadcn/ui + Oxygen + Storefront GraphQL. One Shopify store, one Hydrogen app, deployed on push.
Building the glassmorphic storefront
The design brief was simple: atmospheric, editorial, like flipping through a printed catalog. Dark gradients, blurred glass cards, large type, slow parallax. Every product image sits on a glass-card with backdrop-blur and a soft border.
// app/routes/products.$handle.tsx
import {useLoaderData} from "react-router";
export async function loader({params, context}: LoaderArgs) {
const {handle} = params;
return await context.storefront.query(PRODUCT_QUERY, {
variables: {handle},
cache: context.storefront.CacheShort(),
});
}
export default function Product() {
const {product} = useLoaderData<typeof loader>();
return <GlassCard product={product} />;
}
const PRODUCT_QUERY = `#graphql
query Product($handle: String!) {
product(handle: $handle) {
title
descriptionHtml
featuredImage { url transformedSrc }
variants(first: 10) { nodes { id title price { amount currencyCode } availableForSale } }
}
}
`;
Variants are plain Storefront nodes — availableForSale drives the add-to-cart button state, selectedOptions drives the picker. No custom state machine.
Cart that actually feels native
Hydrogen cart is not a local array — it is a real Shopify cart on the server, identified by a cookie. You call cartLinesAdd and it hits the Storefront Cart API directly.
// Add to cart — single mutation, optimistic UI
export async function action({request, context}: ActionArgs) {
const form = await request.formData();
const variantId = String(form.get("variantId"));
const {cart} = context;
await cart.addLine(variantId, 1);
return json({ok: true});
}
Cart drawer, line quantity, note, discount code — all through useOptimisticData so the UI snaps before the network responds. Shopify checkout URL comes back in one field: cart.checkoutUrl — redirect and you are on Shop Pay.
Performance — why Oxygen is annoyingly fast
Hydrogen on Oxygen is stupid fast — 80ms TTFB from the edge, because data never leaves Shopify network. Storefront queries hit the same PoPs as the admin. CacheShort() (1s) for product pages, CacheLong() (1h) for collections. Images are cdn.shopify.com with automatic srcSet.
Lighthouse on shopify-frost: 99 performance, 100 accessibility, zero CLS on product images because every <Image> knows its aspect ratio upfront.
What I learned shipping it in a weekend
- Do not rebuild product search — Storefront
search+predictiveSearchis already typeahead-ready with one query. - Glassmorphism kills you on low-end Android — keep
backdrop-blurto one layer, not stacked cards. - Oxygen env vars are not Vercel env vars — migrate with
npx shopify hydrogen env pullor you will chase undefined errors. - i18n is a locale prefix in the URL (
/en-us/products/..) — set it on day one or rewrite every link later.
Full source: github.com/Amirabbas-RU/shopify-frost — Hydrogen + Oxygen + Storefront API. If you are building headless on Shopify, clone it, rip out the glass, and make it yours.