This repository provides a reference implementation for building a headless storefront that integrates FirstSpirit Connect for Commerce with Shopify Hydrogen (Remix).
Hydrogen is Shopify’s stack for headless commerce. Hydrogen is designed to dovetail with Remix, Shopify’s full stack web framework. The reference implementations is based on the Hydrogen Demo Store template.
For further information, please refer to the following documentation:
- What's included
- Prerequisites
- Environment variables
- Install dependencies
- Configuring Content Security Policies
- Using Caddy for Local HTTPS Development
- Starting the Development Server
- Port Configuration
- Building for production
- Setup for using Customer Account API (
/accountsection) - Troubleshooting
- Legal Notices
- Disclaimer
- Remix
- Hydrogen
- Oxygen
- Shopify CLI
- ESLint
- Prettier
- GraphQL generator
- TypeScript and JavaScript flavors
- Tailwind CSS (via PostCSS)
- Full-featured setup of components and routes
- FirstSpirit Connect for Commerce Frontend API integration and section components
- Caddy for local HTTPS development
- Shopify store with Storefront API access
- Published Hydrogen or Headless channel/app in Shopify Admin
- Familiarity with the FirstSpirit Connect for Commerce Frontend API. Information can be found in the documentation.
- Node.js version 20.0.0 or higher and npm
- Caddy for local HTTPS development (see below)
Rename .env.template to .env and fill in the fields described below:
| Property | Description |
|---|---|
| SESSION_SECRET | Secret used for session encryption. |
| PUBLIC_STOREFRONT_API_TOKEN | Public API token for accessing the Shopify Storefront API. |
| PUBLIC_STORE_DOMAIN | Your Shopify store domain (e.g. your-shop.myshopify.com). |
| PUBLIC_CUSTOMER_ACCOUNT_API_CLIENT_ID | Client ID for the Shopify Customer Account API. |
| PUBLIC_CHECKOUT_DOMAIN | Domain used for checkout (e.g. checkout.hydrogen.shop). |
| SHOP_ID | The unique ID of your Shopify shop. |
| VITE_ECOM_API_URL | The url to your Frontend API backend service. |
| VITE_ECOM_API_LOCALE | The default locale to use. Default is set to en_GB. |
| VITE_HYDROGEN_BASE_URL | The absolute base URL for the Hydrogen app. |
| VITE_LOG_LEVEL | Numeric representation of log levels:
|
npm installThe CSP configuration is located in app/entry.server.tsx and needs to be customized to allow resources from your FirstSpirit origin and any other domains you need to access.
Replace all placeholder domains in the configuration with your actual domains.
This project uses Caddy as a reverse proxy to enable HTTPS during local development.
brew install caddysudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddychoco install caddySpecify the paths to the SSL certificates in the provided Caddyfile.
If you changed the default port, make sure to update it here accordingly.
Add the following entry to /etc/hosts with sudo privileges:
127.0.0.1 your-domain.comBefore starting Caddy, ensure SSL certificates exist at the specified paths in the Caddyfile.
-
Start your Hydrogen storefront:
# Starts the Hydrogen storefront on port 3020. npm run dev -
Start Caddy in a separate terminal:
# Starts the HTTPS proxy on port 4200. npm run caddy -
Access your application:
https://your-domain.com:4200(HTTPS)http://localhost:3020(HTTP)
- The port for the Vite dev server is configured in
vite.config.ts. It defaults to port3020. - The Caddy HTTPS proxy is configured in the
Caddyfile. It defaults to port4200.
npm run build- Set up Caddy as described above.
- Ensure your Caddy server is running with the HTTPS proxy on port
4200.
- Go to your Shopify admin =>
HydrogenorHeadlessapp/channel => Customer Account API => Application setup. - Edit
Callback URI(s)to includehttps://your-domain.com:4200/account/authorize - Edit
Javascript origin(s)to include your public domainhttps://your-domain.com:4200or keep it blank. - Edit
Logout URIto include your public domainhttps://your-domain.com:4200or keep it blank.
Verify that the defined cert/key paths in the Caddyfile and also the /etc/hosts entry exists.
Ensure that the .env.template was renamed to .env and that the variable names match.
URIs in the Shopify settings must match VITE_HYDROGEN_BASE_URL and the paths above.
Make sure to include https://your-domain.com:4200 in script-src, connect-src, and frame-ancestors in ./app/entry.server.tsx.
When using the HTTPS proxy, set VITE_HYDROGEN_BASE_URL to https://your-domain.com:4200 to avoid redirect and cookie issues.
The Connect for Commerce Frontend API module is a product of Crownpeak Technology GmbH, Dortmund, Germany. The Connect for Commerce Frontend API module is subject to the Apache-2.0 license.
Details regarding any third-party software products in use but not created by Crownpeak Technology GmbH, as well as the third-party licenses and, if applicable, update information can be found here.
This document is provided for information purposes only. Crownpeak may change the contents hereof without notice. This document is not warranted to be error-free, nor subject to any other warranties or conditions, whether expressed orally or implied in law, including implied warranties and conditions of merchantability or fitness for a particular purpose. Crownpeak specifically disclaims any liability with respect to this document and no contractual obligations are formed either directly or indirectly by this document. The technologies, functionality, services, and processes described herein are subject to change without notice.