Deployment
Groundwork deploys to Shopify's Oxygen or to Vercel, from the same code, and CI tests both builds. This doc helps you pick a host, then walks through setting each one up: linking a store for Oxygen, and for Vercel the environment variables and the Customer Account URLs to register in Shopify's Headless channel. It also explains the small layer that differs between the two, so you know which file to open when something only breaks on one host.
It's for a developer shipping a client store, or an agency lead deciding where a project should live. Afterwards you'll know what each host needs from you, why the visitor IP comes from exactly one header, and which parts to check on a real preview deployment before a release.
Related: Architecture for the request lifecycle this layer feeds into, and Testing for how the end-to-end suite runs against both builds.
Source: docs/DEPLOYMENT.md
Groundwork deploys to two hosts, and both are built and tested: Oxygen, Shopify's own hosting, and Vercel. The app code is the same on both. Only a small entry file and the build output differ.
Other hosts (Netlify, Cloudflare Pages and the rest) aren't supported. Hydrogen is built on web standards, so they may work, but nothing here tests them.
Which to choose
| Oxygen | Vercel | |
|---|---|---|
| Cost | Included with paid Shopify plans | Vercel's own pricing |
| Store settings | Filled in when you link the store | You copy them into Vercel's environment variables |
| Customer login | Set up by the Hydrogen sales channel | You register the domain in Shopify's Headless channel |
| Query caching | Oxygen's cache | Vercel's Runtime Cache |
| Where the code runs | Shopify's edge workers | Vercel Node.js functions |
| Deploy | npm run deploy, or Shopify's GitHub integration | Import the repository in Vercel; every push deploys |
| Good fit when | The client is all in on Shopify and wants one vendor and bill | The team already runs its sites on Vercel |
How it works
The two hosts differ in four things, and everything else is shared code. Each host has an entry file at the repo root that gathers those four things and calls handleHostRequest in app/lib/host.ts:
| Need | Oxygen (server.ts) | Vercel (server.vercel.ts) |
|---|---|---|
| Settings | Worker bindings | process.env |
| Query cache | caches.open('hydrogen') | getCache() from @vercel/functions |
| Background work | executionContext.waitUntil | waitUntil from @vercel/functions |
| Visitor IP for Shopify | oxygen-buyer-ip header | x-real-ip header |
deploy-target.ts decides which entry a build uses. A build running on Vercel (which sets VERCEL=1) is a Vercel build, and every other build is an Oxygen build. GROUNDWORK_HOST=oxygen or GROUNDWORK_HOST=vercel overrides that. vite dev runs the app in Shopify's mini-oxygen whichever host you deploy to.
Two details matter if you change this layer:
- The visitor IP comes from one header only. Shopify uses it for bot protection on private Storefront API requests. Each host overwrites its own header, but every other IP header reaches the app exactly as the visitor sent it. Reading a second header as a fallback would let a visitor choose the IP Shopify sees.
- Cache keys skip Vercel's hashing. The Runtime Cache hashes keys to 32 bits by default, so two different queries could share a key and one would get the other's data. Hydrogen already turns each query into a SHA-256 key, so
server.vercel.tspasses keys through unchanged.
Deploying to Oxygen
- Install the Hydrogen sales channel in your Shopify admin and create a storefront.
- Link the project and pull its settings for local work:
``bash npx shopify hydrogen link npx shopify hydrogen env pull ``
- Deploy with
npm run deploy, or connect the repository in the Hydrogen channel so each push deploys.
Oxygen injects the store settings and Customer Account API values from the linked storefront. Add SESSION_SECRET to the storefront's environment variables in the Hydrogen channel.
Deploying to Vercel
- In your Shopify admin, install the Headless sales channel and create a storefront. It gives you the Storefront API tokens.
- In Vercel, import the repository. Vercel detects React Router and runs
npm run build. Leave the build and output settings at their defaults. - Add the environment variables below in the Vercel project, for Production and Preview.
- Deploy. Every push to the production branch deploys, and every pull request gets a preview deployment.
| Variable | Value |
|---|---|
SESSION_SECRET | A long random string. Required. |
PUBLIC_STORE_DOMAIN | your-store.myshopify.com. Without it a production build throws instead of serving demo data. |
PUBLIC_STOREFRONT_API_TOKEN | The Headless channel's public access token. |
PRIVATE_STOREFRONT_API_TOKEN | The Headless channel's private access token. Used only on the server. |
PUBLIC_STOREFRONT_ID | Optional. The storefront ID Shopify's analytics use, if your storefront has one. |
PUBLIC_CHECKOUT_DOMAIN | Your checkout domain, if it differs from the store domain. |
SHOP_ID | The shop's numeric ID. Customer login only. |
PUBLIC_CUSTOMER_ACCOUNT_API_CLIENT_ID | From the Headless channel's Customer Account API settings. Customer login only. |
The app reads only the variables listed in app/lib/env.ts, so other variables in the Vercel project never reach it.
Customer login on Vercel
The Customer Account API only redirects to URLs you register. In the Headless channel's Customer Account API settings, add your production domain:
- Callback URI:
https://your-domain.com/account/authorize - JavaScript origin:
https://your-domain.com - Logout URI:
https://your-domain.com
Preview deployments get a new URL each time, so customer login won't work on them unless you register a stable preview domain too. Everything else does.
Query caching on Vercel
Storefront API queries are cached in Vercel's Runtime Cache, with the same strategies (Cache.short() and the rest) as on Oxygen. How long entries live and where they're stored follows Vercel's rules for that cache.
Testing both hosts
CI runs the end-to-end suite twice: against the dev server (npm run test:e2e), which runs the app in mini-oxygen, and against the Vercel build (npm run build:vercel, then npm run test:e2e:vercel), which runs the Vercel server bundle under Node.js through scripts/serve-vercel-build.mjs.
That script stands in for Vercel's runtime but can't reproduce all of it. The Runtime Cache and waitUntil fall back to an in-memory cache and a no-op outside Vercel. Check those, and customer login, on a preview deployment before a release.