Deploy a Hydrogen app
RequirementsAnchor link to section titled "Requirements"
You're using the most recent version of Hydrogen. The latest release gives you the benefits of performance enhancements, new components, and other best practices.
Deploy to OxygenAnchor link to section titled "Deploy to Oxygen"
Oxygen is Shopify's recommended deployment platform for Hydrogen apps.
Deploy to Node.jsAnchor link to section titled "Deploy to Node.js"
Check the port (
$PORT) that's specified in the
Run your Hydrogen app on the port specified by executing the following commands:
If you're using the default port, then the production version of your app will be running at http://localhost:8080.
Apply extra middlewareAnchor link to section titled "Apply extra middleware"
If you're using the default server entry point in the
build:server script (
@shopify/hydrogen/platforms/node), then the generated server bundle (
dist/server/index.js) consists of a simple Node.js server that uses Connect middleware.
This bundle also exports the
createServer function, which you can call programmatically to apply extra middleware:
Use a different Node.js frameworkAnchor link to section titled "Use a different Node.js framework"
Create a new server entry point (for example,
server.js) and import
Update the scripts in
package.jsonto specify your new entry point. If the scripts are located in
<root>/server.js, then the changes would look like the following:
Run the server bundle:
Use Anchor link to section titled "Use App.server.jsx as the server entry point"
App.server.jsx as the server entry point
If your server isn't compatible with Connect middleware or you're deploying to a serverless platform, then you can directly use the
App.server.jsx file as the server entry point.
Update the scripts in
package.json to specify your new entry point:
This exposes a
handleRequest function that can be imported in your server or serverless function:
Deploy to DockerAnchor link to section titled "Deploy to Docker"
You can deploy your project to any platform that supports Docker-based hosting, like Google Cloud Run, Fly.io, and Heroku. If you've generated a Node.js server, then you can run it inside a Docker container.
Deploy to Cloudflare WorkersAnchor link to section titled "Deploy to Cloudflare Workers"
You can deploy your Hydrogen app to Cloudflare Workers, a serverless application platform. For the Cloudflare Workers' Cache API to work, you need to meet the following requirements:
- You have a Cloudflare domain. The domain can't be
worker.dev, because Cloudflare owns this domain.
- You have a DNS record for the Cloudflare domain. For example,
A example.dev 192.0.2.1 Proxied.
- You have a worker route that points to the Cloudflare domain.
wrangler.tomlfile in the root of your project.
Your static files are now uploaded to Workers KV.
Install Cloudflare's KV asset handler:
Create a new Worker entry file (for example,
worker.js) in your project:
package.jsonto specify the new Worker entry point. If the entry point is in
<root>/worker.js, then the changes look like the following:
Deploy your project with Wrangler:
Deploy to NetlifyAnchor link to section titled "Deploy to Netlify"
To learn how to deploy your Hydrogen app to Netlify, refer to Hydrogen on Netlify.