Deploy a template
This tutorial gets a Hydrogen storefront running from a starter template. You create the storefront from your Shopify store, deploy it to a host, and then set up a local copy to work on.
Anchor to What you'll learnWhat you'll learn
In this tutorial, you'll learn how to do the following tasks:
- Create a storefront from a starter template, and deploy it to Oxygen or Vercel.
- View your deployed storefront, and share it with others.
- Set up a local copy of your storefront that reads from your store.
- Find the parts of the template that fetch data, handle requests, and manage the cart.
Anchor to RequirementsRequirements
- A Shopify store that you can connect a storefront to, and a staff account with permission to manage apps and sales channels.
- Install Node.js. The React Router template needs version 22 or 24, and Vercel Shop needs version 24.
- For the React Router template, a GitHub account. Shopify creates the repository for your storefront in it.
- For Vercel Shop, a Vercel account, a GitHub, GitLab, or Bitbucket account, and pnpm version 12.
Anchor to Step 1: Create and deploy your storefrontStep 1: Create and deploy your storefront
You can start from one of two templates that are built on Hydrogen. Shopify maintains the React Router template, and Vercel maintains Vercel Shop. Each one comes with a home page, collection pages, product pages, search, and a cart already built. The React Router template also includes customer accounts, analytics, and a consent banner. Vercel Shop includes customer accounts and Shopify analytics too, but you need to enable them to use them.
| Template | Framework | Hosting |
|---|---|---|
| React Router | React Router 7 | Oxygen |
| Vercel Shop | Next.js 16 App Router | Vercel |
Pick the template that matches your framework, and follow its steps:
React Router on Oxygen
You create the storefront in the Hydrogen channel in your Shopify admin. Shopify creates a GitHub repository from the template, connects it to your store, and deploys it to Oxygen every time you push.
-
Click Deploy to Oxygen:
Your Shopify admin opens at the Hydrogen channel. If you haven't installed the Hydrogen channel yet, then install it when the admin asks you to. The admin then opens the page for creating a storefront.
-
In Storefront name, enter a name for your storefront. You can change the name later.
-
Under Deployment setup, keep Set up GitHub continuous deployment now selected.
-
If you haven't connected GitHub to your store before, then click Connect GitHub, and install the Shopify GitHub app on the account or organization that you want to use.
-
Select your GitHub account or organization. In Find or create a repository, enter a name for your repository, and then select Create followed by the name.
The repository is private unless you select the checkbox to make it public. Shopify adds the template only to a new repository, so don't select an existing one.
-
Click Create.
Shopify generates your store's Storefront API and Customer Account API tokens, creates your storefront's environments, and creates the repository with the template and a GitHub Actions workflow. The workflow deploys your storefront to Oxygen.
-
Wait for the first deployment to finish. Your storefront's overview page shows that the storefront is building. To follow its progress, click View GitHub Actions. When the deployment finishes, the overview page shows your storefront's URL.
Open the URL to see your storefront. It shows your store's products, and the checkout button in the cart opens your store's checkout.
Oxygen environments are private by default, so only staff who are logged in to your store can open the URL. To show your storefront to someone else, share a deployment with a link, or make the environment public. Development stores and stores on a trial plan can't have public environments.
Vercel Shop
Vercel Shop reads from your store through a storefront in the Headless channel. Set up that storefront first, so you have the values that Vercel asks for when you deploy.
- Install the Headless channel on your store.
- In your Shopify admin, under Sales channels, click Headless, and then click Create storefront. If you already have a Headless storefront, then click Add storefront instead.
- On your new storefront's page, copy the public access token.
- Beside Storefront API permissions, click Edit, and select the permissions that Vercel Shop needs. For the list, refer to Vercel Shop's Storefront API permissions. Click Save.
- Publish the products and collections that you want to show to the Headless channel. Products that are published only to the Online Store channel don't appear in Vercel Shop.
- Find your store's
myshopify.comdomain in Settings > Domains. Find your shop ID in your store's customer accounts URL. It's the number in the URL, like123456789inhttps://shopify.com/123456789/account.
Then deploy Vercel Shop:
-
Click Deploy, and log in to Vercel:
-
Choose your Git provider and the account to create the repository in, and enter a name for the repository.
-
Enter your store domain, public access token, and shop ID in the environment variables that Vercel asks for. The build fails if any of them is missing.
-
Click Deploy, and wait for the build to finish.
When the build finishes, Vercel shows your project's production URL. Open it to see your storefront. If the storefront doesn't show any products, then check the token's permissions, and check that your products are published to the Headless channel.
Your production URL, like shop.vercel.app, is public. The URL of each individual deployment is protected by Vercel's Deployment Protection by default, so visitors need to log in to Vercel to open it.
You create the storefront in the Hydrogen channel in your Shopify admin. Shopify creates a GitHub repository from the template, connects it to your store, and deploys it to Oxygen every time you push.
-
Click Deploy to Oxygen:
Your Shopify admin opens at the Hydrogen channel. If you haven't installed the Hydrogen channel yet, then install it when the admin asks you to. The admin then opens the page for creating a storefront.
-
In Storefront name, enter a name for your storefront. You can change the name later.
-
Under Deployment setup, keep Set up GitHub continuous deployment now selected.
-
If you haven't connected GitHub to your store before, then click Connect GitHub, and install the Shopify GitHub app on the account or organization that you want to use.
-
Select your GitHub account or organization. In Find or create a repository, enter a name for your repository, and then select Create followed by the name.
The repository is private unless you select the checkbox to make it public. Shopify adds the template only to a new repository, so don't select an existing one.
-
Click Create.
Shopify generates your store's Storefront API and Customer Account API tokens, creates your storefront's environments, and creates the repository with the template and a GitHub Actions workflow. The workflow deploys your storefront to Oxygen.
-
Wait for the first deployment to finish. Your storefront's overview page shows that the storefront is building. To follow its progress, click View GitHub Actions. When the deployment finishes, the overview page shows your storefront's URL.
Open the URL to see your storefront. It shows your store's products, and the checkout button in the cart opens your store's checkout.
Oxygen environments are private by default, so only staff who are logged in to your store can open the URL. To show your storefront to someone else, share a deployment with a link, or make the environment public. Development stores and stores on a trial plan can't have public environments.
Anchor to Step 2: Set up your local copyStep 2: Set up your local copy
To work on the code, clone the repository that you created in Step 1, and install dependencies:
Terminal
React Router
git clone <your-repository-url> my-store
cd my-store
npm installVercel Shop
git clone <your-repository-url> my-store
cd my-store
pnpm installYour hosted storefront already has your store's credentials, but your local copy doesn't. Add them as described for your template.
The private Storefront API token is server-only. Never expose it to the browser, and never give it a browser prefix like NEXT_PUBLIC_.
Anchor to React Router on OxygenReact Router on Oxygen
Oxygen keeps your storefront's environment variables in the Shopify admin. To copy them to your local copy, run the following commands from your project's directory. link connects the directory to a storefront in the Shopify admin, so select the storefront that you created in Step 1. env pull copies the storefront's environment variables into .env:
Terminal
To use an existing private Storefront API token without linking, add your store domain and token to .env instead:
Store connection
.envPUBLIC_STOREFRONT_ID is optional. Shopify analytics turn on when it's set. The template gets your shop ID from the Storefront API, so you don't set it for analytics.
Until it finds a private Storefront API token, the React Router template reads demo data from mock.shop instead of your store.
Anchor to Vercel ShopVercel Shop
Copy .env.example to .env.local, and set the same store domain, public access token, and shop ID that you entered in Vercel:
Store connection
.env.localThe first three variables are required. NEXT_PUBLIC_SHOPIFY_STOREFRONT_ID is optional, and attributes storefront traffic and analytics to your Headless storefront. Find it in the storefront's URL in the Headless channel. It's the number after /headless/. For other settings, refer to Vercel Shop's environment variables.
When you change a variable later, also change it in your Vercel project's Settings > Environment Variables, and then redeploy.
Anchor to Customer accountsCustomer accounts
Both templates include customer accounts, but they need extra environment variables and HTTPS (a public tunnel for local Vercel Shop sign-in). On Oxygen, your storefront provides the variables. To learn about setting them up, refer to Set up customer accounts. In Vercel Shop, customer accounts are off by default. To turn them on, refer to Vercel Shop's authentication guide.
Anchor to Step 3: Run your storefrontStep 3: Run your storefront
Start the development server:
Terminal
React Router
npm run devVercel Shop
pnpm devOpen the local URL that the command prints. The React Router template runs at http://localhost:5173, and Vercel Shop runs at http://localhost:3000.
Your local storefront shows your store's products, like your deployed one. Browse a collection, open a product, choose a variant, and add it to your cart. The cart drawer opens with your item.
Anchor to Step 4: Explore your storefrontStep 4: Explore your storefront
Each template is an ordinary app for its framework. Hydrogen adds three things to it:
- Request handlers that run before your router, and serve the routes that every Shopify storefront needs, like
/api/cartand cart permalinks. - A Storefront API client that your pages use to fetch products, collections, and other store data.
- Cart state that every component that shows the cart shares, and that stays in sync with Shopify.
The following table shows where to find each part in each template:
| Part | React Router | Vercel Shop |
|---|---|---|
| Pages | app/routes/, registered in app/routes.ts | app/ |
| Request handlers | The middleware export in app/root.tsx | proxy.ts |
| Shopify redirects, which run after your router returns a 404 | The middleware export in app/root.tsx | app/not-found.tsx, enabled by redirects.shopifyNotFound.isEnabled |
| Storefront API client | app/lib/storefront.ts | lib/shopify/storefront/server.ts |
| Queries | In each route's file | lib/shopify/operations/ |
| Route templates | app/lib/route-templates.ts | lib/shopify/routing/index.ts |
| Cart | app/lib/cart-handlers.ts, app/lib/cart.ts, and app/components/CartDrawer.tsx | lib/cart/server.ts, lib/cart/client.ts, and components/cart/ |
| Store settings | app/lib/shop.ts | lib/config/index.ts |
| Styles | app/tokens.css and app/app.css | app/globals.css |
In the React Router template, open the home page's file, app/routes/home.tsx, and find the Home query that fetches the products and collections that the page shows. To show more data on the page, add fields to that query. In Vercel Shop, find the queries for each page in lib/shopify/operations/. To learn how queries work, refer to Query the Storefront API.