1 MIN READ

Three things to fix before going live on Hydrogen

Edge runtime gotchas, cart hydration, and the SEO trap most teams miss.

BY RAHUL MEHTAUPDATED
Illustration for “Three things to fix before going live on Hydrogen” — Hydrogen

Hydrogen is fast — until you ship to prod and discover the three gotchas every team hits.

Shopify's default cart cookie can balloon past Cloudflare's 4KB header limit when you add line-item attributes. Trim it before deploy.

2. Cart hydration

The default useCart hook re-fetches on every navigation. Pin it to a route segment, not the root layout.

3. The SEO trap

Hydrogen renders product pages on demand. Without a canonical sitemap.xml + Open Graph passthrough, Google indexes your fallback shell. We learned this once. Never again.

app/root.tsxtypescript
// Trim the cart cookie before it reaches the edge.
export function trimCart(cart: Cart): Cart {
  return {
    ...cart,
    lines: cart.lines.map(({ attributes, ...line }) => line),
  }
}
Without a canonical sitemap, Google indexes your fallback shell.
↳ Rahul Mehta
[ Keep reading ]