Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Shopify Engineering 13 min read Case study mediumAdept

How We Built Hydrogen: A React Framework for Building Custom Storefronts

Hydrogen, Shopify's React framework for custom storefronts, was built on React Server Components, React 18 streaming SSR and Vite, chosen over static JAMStack approaches because commerce pages are inherently dynamic. Component-level data fetching replaced route loaders, and a preload cache hoists nested queries so they run in parallel instead of in network waterfalls. Removing bloated exported GraphQL fragments and adding a logger for unused query fields cut some demo store route load times in half. Rigid "magical" context-based components were dropped in favor of leaner primitives, and the team describes its early reverse-engineered RSC implementation and collaboration with the React, Vite, Vercel and Cloudflare teams.

Assumes: React components and hooksserver-side renderingGraphQL queries

Related posts

  • Building Blocks of High Performance Hydrogen-powered Storefronts

    Shopify Engineering easyNovice

    Hydrogen, Shopify's React-based storefront framework, targets the tension between fast loading and personalized, dynamic commerce by combining React 18 streaming SSR with Suspense, React Server Components, cache-aware data fetching, and per-page edge caching. Streaming SSR sends the HTML shell immediately for a fast TTFB, then streams data and progressively hydrates components, avoiding the client-side fetch waterfall that slows LCP under CSR. On Oxygen, a V8 isolate worker runtime colocated with Shopify data, server components query the Storefront API at near-localhost latency, and third-party fetches get default cache keys, TTLs and stale-while-revalidate. Static pages can be served from the CDN edge, with the choice of SSR, client fetching or edge delivery made per page and per component.

  • Rapid Development with Hydrogen: Building a Product Page

    Shopify Engineering mediumAdept

    Hydrogen, Shopify's React-based storefront framework, can produce a working product display page quickly by composing its built-in commerce components and hooks. The walkthrough starts from the Hello World template on StackBlitz, adds Tailwind CSS, and creates a dynamic `/products/[handle]` route via file-based routing. Product data comes from the Storefront API through `useShopQuery`. A client component wrapped in `ProductOptionsProvider` handles variant selection and price, while `BuyNowButton` and a media gallery component finish the page. It also shows where the server/client component split matters when state is needed.

  • Best-in-Class Developer Experience with Vite and Hydrogen

    Shopify Engineering easyNovice

    Shopify's Hydrogen storefront framework is built on Vite. Vite serves user code as native ES Modules and pre-bundles and caches only third-party dependencies, which speeds up dev-server startup and hot module replacement compared with bundle-based tools like Webpack. Other reasons cited for the choice are ESBuild-based transforms, Rollup plugin compatibility, automatic CJS-to-ESM conversion, and SSR hooks that allow environment-specific transforms needed for React Server Components. Hydrogen wraps this in a single Vite plugin that composes four sub-plugins (hydrogen-config, react-server-dom-vite, hydrogen-middleware, plugin-react), while Webpack remains a fit for some advanced use cases.

  • React Server Components Best Practices You Can Use with Hydrogen

    Shopify Engineering mediumAdept

    When building React Server Components applications, start every new component as a shared component, extract only the genuinely client-side pieces (interactivity, useState/useReducer, useEffect, browser APIs, RSC-incompatible libraries) into small .client components, and convert the rest to .server components whenever the code never needs to or should not run on the client. Server components can still be rendered inside client components by passing them as children rather than importing them, which avoids inflating the client bundle. Two Hydrogen starter examples, a footer newsletter sign-up and a product FAQ accordion, show the refactoring steps, with the bundle shrinking because only the form and accordion logic ship to the browser.

  • A Gentle Introduction to Islands

    Deno mediumAdept

    Islands architecture renders pages as static HTML and hydrates only isolated interactive Preact components, avoiding the whole-page, top-down hydration that ships framework JS even for static content. Fresh implements it by reading islands from the generated fresh.gen.ts manifest and using Preact's options.vnode hook during SSR to wrap each island in frsh-id:index HTML comments. It then emits a hydration script only when islands were encountered. In the browser, a revive function walks the DOM for those comments and renders each component with its serialized props, so pages with no islands ship zero JavaScript. Astro's client directives, partial hydration in Marko, React Server Components and Qwik's resumability are compared as alternative approaches.

The quest for software engineering knowledge.

Look:
Layout: