--- title: Hydrogen and Oxygen fundamentals description: Learn about how the Hydrogen and Oxygen stack works, how Hydrogen projects are structured, and how they work with the rest of Shopify. source_url: html: https://shopify.dev/docs/storefronts/headless/hydrogen/fundamentals md: https://shopify.dev/docs/storefronts/headless/hydrogen/fundamentals.md --- ExpandOn this page * [Architecture](https://shopify.dev/docs/storefronts/headless/hydrogen/fundamentals#architecture) * [Hydrogen](https://shopify.dev/docs/storefronts/headless/hydrogen/fundamentals#hydrogen) * [React Router](https://shopify.dev/docs/storefronts/headless/hydrogen/fundamentals#react-router) * [Oxygen](https://shopify.dev/docs/storefronts/headless/hydrogen/fundamentals#oxygen) * [Next steps](https://shopify.dev/docs/storefronts/headless/hydrogen/fundamentals#next-steps) # Hydrogen and Oxygen fundamentals Hydrogen and Oxygen make up Shopify's recommended stack for headless commerce. The different parts of the system work together to make it faster and easier to build and deploy headless Shopify stores. *** ## Architecture Three key parts of the Hydrogen stack work together to enable a unified developer experience: | Technology | What it does | | - | - | | [**Hydrogen**](#hydrogen) (App) | A set of components, utilities, and design patterns that make it easier to work with Shopify APIs. Hydrogen projects are React Router apps that are preconfigured with Shopify-specific features and functionality. Hydrogen handles API client credentials, provides off-the-shelf components that are pre-wired for Shopify API data, and includes CLI tooling for local development, testing, and deployment. | | [**React Router**](#react-router) (Framework) | The open-source React framework that Hydrogen is built on top of. React Router handles routing, data fetching, server-side rendering, UI reactivity, and styling. | | [**Oxygen**](#oxygen) (Hosting) | Shopify’s global serverless hosting platform, built for deploying Hydrogen storefronts at the edge. Oxygen handles deployment environments, environment variable management, caching, and integration with Shopify’s CDN. | Developing each layer of this tech stack together means provides an end-to-end developer experience that reduces boilerplate code, improves productivity, and promotes optimal performance, accessibility, and SEO practices. *** ## Hydrogen ### Project structure Hydrogen projects are structured like typical [React Router](#react-router) apps and you can configure them to your preferences. The following is the default [Quickstart](https://shopify.dev/docs/storefronts/headless/hydrogen/getting-started) project structure: ## Hydrogen project structure ```sh πŸ“‚ hydrogen-quickstart/ β”œβ”€β”€ πŸ“ app/ β”‚ β”œβ”€β”€ πŸ“ assets/ β”‚ β”œβ”€β”€ πŸ“ components/ β”‚ β”œβ”€β”€ πŸ“ graphql/ β”‚ β”œβ”€β”€ πŸ“ lib/ β”‚ β”œβ”€β”€ πŸ“ routes/ β”‚ β”œβ”€β”€ πŸ“ styles/ β”‚ β”œβ”€β”€ entry.client.jsx β”‚ β”œβ”€β”€ entry.server.jsx β”‚ └── root.jsx β”œβ”€β”€ πŸ“ public/ β”œβ”€β”€ CHANGELOG.md β”œβ”€β”€ README.md β”œβ”€β”€ customer-accountapi.generated.d.ts β”œβ”€β”€ env.d.ts β”œβ”€β”€ jsconfig.json β”œβ”€β”€ package.json β”œβ”€β”€ postcss.config.js β”œβ”€β”€ server.js β”œβ”€β”€ storefrontapi.generated.d.ts └── vite.config.js ``` ### Packages and dependencies Hydrogen bundles a set of dependencies that work together to enable end-to-end development and deployment: | Package | Description | | - | - | | `@shopify/hydrogen` | Main Hydrogen package. Contains components specific to React Router and utilities for interacting with Shopify APIs. Extends the framework-agnostic [`@shopify/hydrogen-react`](https://shopify.dev/docs/api/hydrogen-react) package. | | `@shopify/hydrogen-cli` | CLI tool for working with Hydrogen projects. | | `@shopify/mini-oxygen` | Local development server based on Oxygen. | | `@shopify/remix-oxygen` | [Remix adapter](https://remix.run/docs/en/main/pages/technical-explanation#http-handler-and-adapters) that enables Hydrogen to be served on [Oxygen](#oxygen). | ### Hydrogen channel The [Hydrogen sales channel app](https://apps.shopify.com/hydrogen) needs to be installed on your Shopify store to enable the following features: * A Hydrogen sales channel where you can publish product inventory. * [Oxygen](#oxygen) hosting, to deploy your Hydrogen projects. * Managing [storefronts](https://shopify.dev/docs/storefronts/headless/hydrogen/storefronts) and deployment [environments](https://shopify.dev/docs/storefronts/headless/hydrogen/environments), including environment variable management. * Access to deployment logs. ### Routes The standard format for product URLs is `/products/:handle`. If your storefront uses a different structure, then it's recommended that you provide a server-side redirect (3XX) from the expected `/products/:handle` path to the product page. It's also recommended that your storefront supports [cart permalinks](https://help.shopify.com/en/manual/checkout-settings/cart-permalink). [View example implementation](https://github.com/Shopify/hydrogen-demo-store/blob/b19212adc431c9ee3c510f022ee994bb5d24b0df/app/routes/\(%24locale\).cart.%24lines.tsx) *** ## React Router React Router is the open-source React-based framework that Hydrogen is built on top of. Hydrogen projects are React Router apps with a set of preconfigured options, bundled with a collection of Shopify-optimized components and utilities. Hydrogen includes a custom React Router adapter that compiles your project for hosting on [Oxygen](#oxygen). Tip Consider completing React Router's 30-minute [getting started tutorial](https://reactrouter.com/6.30.0/start/tutorial) for a solid foundation on the architecture and conventions of React Router apps. ### Key React Router concepts | Concept | Details | | - | - | | [Nested routes](https://reactrouter.com/start/declarative/routing#nested-routes) | React Router maps the nesting logic of app URLs to the nesting logic of components and data-loading. This allows all page data to load in parallel, reducing overall load times. | | [Loaders](https://reactrouter.com/start/framework/data-loading) | React Router loaders are functions that load data so that it can be rendered server-side, which reduces the amount of JavaScript that's sent to the client. In Hydrogen, loaders fetch data from Shopify APIs and third-party sources. | | [Actions](https://reactrouter.com/start/framework/actions) | React Router actions are functions that accept web-standard form data from clients in order to update state, mutate data, or trigger side effects. | | [SSR](https://reactrouter.com/how-to/pre-rendering#configuration) | React Router apps default to server-side rendering (SSR), where their React components are rendered as HTML before being sent to the browser. | | [Progressive enhancement](https://reactrouter.com/explanation/progressive-enhancement) | Because React Router actions use web standard technology like HTML forms, they typically work without JavaScript, but can be enhanced with client-side JavaScript when it's available. This, along with an SSR-first approach, means React Router apps typically deliver smaller bundle sizes that load faster. | *** ## Oxygen ![Diagram of how Oxygen interacts with your local Hydrogen project, the Shopify admin, GitHub, and the customer](https://cdn.shopify.com/shopifycloud/shopify-dev/production/assets/assets/images/custom-storefronts/oxygen/oxygen-diagram-BDJ91xEm.png) Oxygen is Shopify’s global deployment platform that's built for hosting Hydrogen storefronts at the edge. It provides multiple deployment environments, so you can preview every change before shipping it to production. Oxygen supports continuous deployment using [GitHub](https://shopify.dev/docs/storefronts/headless/hydrogen/deployments/github), or you can configure your own [custom CI/CD](https://shopify.dev/docs/storefronts/headless/hydrogen/deployments/custom-ci-cd) system. Enable access to Oxygen by installing the [Hydrogen channel](#hydrogen-channel). ### Supported plans Oxygen is available at no extra charge on paid Shopify plans: * Pause and build * Basic * Shopify * Advanced * Plus Oxygen isn't available on Starter plans or development stores. ### Technical specs Oxygen is a worker-based JavaScript runtime, based on Cloudflare’s open-source [`workerd`](https://github.com/cloudflare/workerd) library. It supports web standard APIs such as Fetch, Cache, Streams, Web Crypto, and more. Some Node.js APIs aren't available. Check the [Oxygen runtime](https://shopify.dev/docs/storefronts/headless/hydrogen/deployments/oxygen-runtime) details for a complete list. If you prefer, you can [self-host Hydrogen](https://shopify.dev/docs/storefronts/headless/hydrogen/deployments/self-hosting). ### Limitations You can use Oxygen for hosting commerce storefronts. It's subject to the Shopify [Acceptable Use Policy](https://www.shopify.com/legal/aup). Misuse or abuse of Oxygen might lead to throttling, suspension, or termination. * **Workers:** * Must be 10 MB or less * The startup time (the duration it takes for the worker to begin processing requests) must be 400 milliseconds or less. * Must be named `index.js`. The optional source map file must be named `index.js.map`. * Are limited to 30 seconds of CPU time per request * Can consume 128 MB max of memory. Exceeding this limit could mean dropped requests. * Are limited to 110 [custom environment variables](https://shopify.dev/docs/storefronts/headless/hydrogen/environments#environment-variables) * Outbound API requests must complete within 2 minutes * **Static assets, maximum file sizes:** * Images: 20 MB * Video: 1 GB * 3D models: 500 MB * Other files: 20 MB Caution Ensure your requests go directly to Oxygen. Because proxies can conflict with Oxygen's bot mitigation systems and cause SEO issues, Oxygen doesn't support proxies in front of your Oxygen deployments. *** ## Next steps [![](https://shopify.dev/images/icons/48/graphql.png)![](https://shopify.dev/images/icons/48/graphql-dark.png)](https://shopify.dev/docs/storefronts/headless/hydrogen/data-fetching) [Fetch product data from Shopify](https://shopify.dev/docs/storefronts/headless/hydrogen/data-fetching) [Learn how to query Shopify’s Storefront API for product data and render it in Hydrogen.](https://shopify.dev/docs/storefronts/headless/hydrogen/data-fetching) *** * [Architecture](https://shopify.dev/docs/storefronts/headless/hydrogen/fundamentals#architecture) * [Hydrogen](https://shopify.dev/docs/storefronts/headless/hydrogen/fundamentals#hydrogen) * [React Router](https://shopify.dev/docs/storefronts/headless/hydrogen/fundamentals#react-router) * [Oxygen](https://shopify.dev/docs/storefronts/headless/hydrogen/fundamentals#oxygen) * [Next steps](https://shopify.dev/docs/storefronts/headless/hydrogen/fundamentals#next-steps)