Development example for exercising Hydrogen APIs in Nuxt. This is not a starter template. See
../README.mdfor context.
Port of the canonical examples/core design to Nuxt 3 with SSR on the Nitro Node server.
- Nitro server middleware (
server/middleware/shopify.ts) as the request entry point — it creates the request-scoped Storefront client and handles Hydrogen routes. useFetchinpages/as the data path — pages read from Nitro routes underserver/api/.- Tailwind v4 via
@tailwindcss/vite— the design's@themetokens live inassets/css/main.css.
storefront/storefront-config.ts selects the mode for each request from server environment variables:
- Mock mode uses
mock.shop. The example uses it whenPRIVATE_STOREFRONT_API_TOKENis absent or empty, whenMOCK_SHOP=1, or whenPUBLIC_STORE_DOMAINismock.shopor a*.mock.shopsubdomain (even if a token is set). A supportedmock.shopsubdomain inPUBLIC_STORE_DOMAINstays selected in all of these cases. - Private mode uses the shared store from
examples/shared/config.tswith that store's private Storefront API token inPRIVATE_STOREFRONT_API_TOKEN. APUBLIC_STORE_DOMAINthat is not amock.shopdomain is ignored, because the token, Customer Account, and Shopify script identity all belong to the shared store.
Customer Account is disabled in mock mode.
For development, authorized developers with the ejson key set up can run:
pnpm run examples:secrets:decryptThis writes the shared store's private token to the Git-ignored examples/nuxt/.env, which nuxt dev loads.
The account flow uses Customer Account values from examples/shared/config.ts and an encrypted HttpOnly __Host- cookie adapter from examples/shared/customer-session.ts. It is only available in private mode.
Customer Account OAuth requires a public HTTPS origin. To test locally without a tunnel, build the workspace packages first (pnpm run build:pkgs), then run:
pnpm --filter @shopify/hydrogen-example-nuxt dev:httpsOn the first run, you may need to restart the command after the Vite plugin provisions the certificate so Nuxt can load it.
The local HTTPS plugin can download mkcert, create and trust a local certificate authority, create certificates, link an unlinked Hydrogen storefront, and push the Customer Account callback, JavaScript origin, and logout URLs to that storefront. If automatic setup is unavailable, it prints the values for manual configuration.
# from the repo root
pnpm install
pnpm run dev:nuxtdev:nuxt builds the workspace packages that the example depends on, then starts nuxt dev. Then open http://localhost:3000.
To build and serve the production output:
pnpm turbo run build --filter=@shopify/hydrogen-example-nuxt...
pnpm --filter @shopify/hydrogen-example-nuxt startpnpm start runs the Nitro Node server (node .output/server/index.mjs) and listens on port 3000 by default (set PORT to change it). This server does not load .env. Set PRIVATE_STOREFRONT_API_TOKEN (and optionally MOCK_SHOP or PUBLIC_STORE_DOMAIN) in the server process environment, for example from your host's secret store. Without the token, the production server runs in mock mode.