Shopify CLI commands for Hydrogen storefronts
This reference lists the commands that you can use while developing and building Hydrogen storefronts with the Shopify CLI.
The sections below describe how to perform all Hydrogen-related tasks, such as creating a new Hydrogen storefront, running it locally for development and building it for production deployments.
Command | Description |
---|---|
init | Creates a new Hydrogen storefront. |
dev | Runs a Hydrogen storefront in a local runtime which emulates an Oxygen worker for development. |
build | Builds a Hydrogen storefront for production. |
preview | Runs a production build of a Hydrogen storefront for a local preview. |
check | Returns diagnostic information about a Hydrogen storefront. |
codegen-unstable | Generates types for the Storefront API queries found in your project. |
shortcut | Creates a global h2 shortcut for Shopify CLI using shell aliases. |
list | Lists all of the Hydrogen storefronts available to link to your local development environment. |
link | Links your local development environment to a remote Hydrogen storefront. |
unlink | Unlinks your local development environment from a remote Hydrogen storefront. |
env list | Lists all of the environments available on the linked Hydrogen storefront. |
env pull | Pulls environment variables from the linked Hydrogen storefront and writes them to an .env file. |
Creates a new Hydrogen storefront.
Flag | Description |
---|---|
--path |
Sets the path to the directory of the new Hydrogen storefront. Example: --path hydrogen-storefront . |
--language |
Sets the template language to use. LANGUAGE be either js for JavaScript or ts for TypeScript. Example: --language js |
--install-deps |
Auto installs dependencies using the active package manager. |
--no-install-deps |
Skips the prompt for installing dependencies. |
--mock-shop |
Uses mock.shop as the data source for the storefront. A Shopify account isn't required. |
--styling |
Chooses one of the available styling options. Must be one of tailwind , css-modules , vanilla-extract , postcss , or none . Example: --styling tailwind . |
--markets |
Sets the URL structure to support multiple markets. Must be one of: subfolders , subdomains , domains , or none . Example: --markets subfolders . |
--shortcut |
Creates a global h2 shortcut for Shopify CLI using shell aliases. |
--no-git |
Skips intializing Git and adding initial commits. |
--force |
Overwrites the destination directory and files if they already exist. |
Runs a Hydrogen storefront in a local runtime which emulates an Oxygen worker for development.
If your project is linked to a Hydrogen storefront, then its environment variables will be loaded with the runtime.
Flag | Description |
---|---|
--disable-virtual-routes |
Disables rendering fallback routes when a route file doesn't exist. |
--worker-unstable |
Runs the app in a worker environment closer to Oxygen production instead of a Node.js sandbox. |
--no-sourcemap |
Skips generating sourcemaps for the development build. |
--debug |
Attaches a Node inspector to the development server. |
--env-branch |
If linked to a Hydrogen storefront, specifies the environment to pull variables for, using its associated branch name. Example: --env-branch='staging' |
--codegen-unstable |
Generates types for the Storefront API queries found in your project. It updates the types on file save. |
--codegen-config-path |
Specifies a path to a codegen configuration file. Defaults to <root>/codegen.ts if this file exists. |
--port PORT |
The Port to run the server on. The default is 3000 . |
--path PATH |
The path to the directory of the Hydrogen storefront. The default is the current directory where the command is run. |
Builds a Hydrogen storefront for production.
Flag | Description |
---|---|
--disable-route-warning |
Disables any warnings about missing standard routes. |
--no-sourcemap |
Skips generating sourcemaps for the build. |
--no-bundle-stats |
Skips showing the bundle size summary after building. |
--no-lockfile-check |
Skips warning about invalid lockfiles in the project. When running on CI, invalid lockfiles don't stop the build. |
--codegen-unstable |
Generates types for the project's Storefront API queries. |
--codegen-config-path |
Specifies a path to a codegen configuration file. Defaults to <root>/codegen.ts if this file exists. |
--path PATH |
The path to the directory of the Hydrogen storefront. The default is the current directory where the command is run. |
Runs a production build of a Hydrogen storefront for a local preview.
Flag | Description |
---|---|
--worker-unstable |
Runs the app in a worker environment that's closer to Oxygen production, instead of a Node.js sandbox. |
--env-branch |
Specifies the environment to pull variables for, using its associated branch name. |
--port PORT |
The Port to run the server on. The default is 3000 . |
--path PATH |
The path to the directory of the Hydrogen storefront. The default is the current directory where the command is run. |
Returns diagnostic information about the Hydrogen storefront.
Checks the Hydrogen storefront for missing standard Shopify routes.
Flag | Description |
---|---|
--path PATH |
The path to the directory of the Hydrogen storefront. The default is the current directory where the command is run. |
Generates types for the Storefront API queries found in your project.
Flag | Description |
---|---|
--watch |
Watches the project for changes to update types on file save. |
--codegen-config-path |
Specifies a path to a codegen configuration file. Defaults to <root>/codegen.ts if this file exists. |
Creates a global h2
shortcut for Shopify CLI using shell aliases.
The following shells are supported:
- Bash (using
~/.bashrc
) - ZSH (using
~/.zshrc
) - Fish (using
~/.config/fish/functions
) - PowerShell (added to
$PROFILE
)
After the alias is created, you can call Shopify CLI from anywhere in your project using the following commands:
The h2
alias runs the local version of Shopify CLI installed in the current project.
Lists all Hydrogen storefronts available to link to your local development environment.
Flag | Description |
---|---|
--shop |
This flag is deprecated. Specifies a myshopify.com domain to authenticate with. |
--path PATH |
The path to the directory of the Hydrogen storefront. The default is the current directory where the command is run. |
Links your local development environment to a remote Hydrogen storefront. You can have any number of local development environments linked to the same Hydrogen storefront.
Linking to a Hydrogen storefront enables you to run dev
and automatically inject all of your linked Hydrogen storefront's environment variables directly into the server runtime.
After you run the link
command, you can access the env list
, env pull
, and unlink
commands.
Flags
| Flag | Description | | --- | --- | |--storefront
| The name of the storefront to link. |
| --force
| Skips confirmation and overwrite any existing link. |
| --shop
| This flag is deprecated. Specifies a myshopify.com domain to authenticate with. |
| --path PATH
| The path to the directory of the Hydrogen storefront. The default is the current directory where the command is run. |
Unlinks your local development environment from a remote Hydrogen storefront.
Flag | Description |
---|---|
--path PATH |
The path to the directory of the Hydrogen storefront. The default is the current directory where the command is run. |
Lists all environments available on the linked Hydrogen storefront.
Flag | Description |
---|---|
--shop |
This flag is deprecated. Specifies a myshopify.com domain to authenticate with. |
--path PATH |
The path to the directory of the Hydrogen storefront. The default is the current directory where the command is run. |
Pulls environment variables from the linked Hydrogen storefront and writes them to an .env
file.
Flag | Description |
---|---|
--env-branch |
Specifies the environment to pull variables for, using its associated branch name. |
--force |
Skips confirmation and overwrite the values for any keys that have been pulled. |
--shop |
This flag is deprecated. Specifies a myshopify.com domain to authenticate with. |
--path PATH |
The path to the directory of the Hydrogen storefront. The default is the current directory where the command is run. |