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
Runnpm install
to install necessary dependencies. -
Environment Configuration
Usenpx 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. -
Start the Development Server
Runnpm 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.