Setting Up Localhost for Development
Setting up your local development environment is a crucial step in the development process.
The Customizer allows you to preview your local storefront in real-time, making it easy to test your changes before pushing them to production.
-
Clone the Repository Start by cloning the storefront's repository to your local machine.
-
Install Dependencies Run
npm install
to install necessary dependencies. -
Environment Configuration Use
npx shopify hydrogen env pull
for a quick environment setup. This will pull the necessary environment configurations. Alternatively, you can manually copy and paste the environment variables from Shopify.Please double check the
.env
file to ensure all necessary variables are present. If you setPACK_SECRET_TOKEN
as a secret environment variable in Shopify, you must manually add it to your.env
file. -
Start the Development Server Run
npm run dev
to start the development server. Your local storefront will be available athttp://localhost:8080
.
Additional Setup
Adding a Localhost Preview URL to the Customizer In order to preview your local storefront in Customizer, you will need to add your localhost URL to the Customizer preview URLs.
- Navigate to the Customizer.
- Select the preview URL dropdown (located below the Publish button).
- Click on "Edit preview URLs."
- Add your new URL and click Save.
