> ## Documentation Index
> Fetch the complete documentation index at: https://weaverse.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Weaverse component configuration uses `settings`. `inspector` is deprecated; never generate it.
> Weaverse Hydrogen themes use React Router v7: import from `react-router`, never `react-router-dom` or `@remix-run/*`.
> Before using any code sample, read `@weaverse/hydrogen` in the project's `package.json`: 6.x and 5.x import from different entries and use different type names, so code for one does not build on the other.
> `@weaverse/hydrogen` 6 (Shopify Hydrogen 2026.10 and later, the version these docs show) imports from `@weaverse/hydrogen/react-router` and uses `Weaverse*` types such as `WeaverseComponentProps`, `WeaverseComponentLoaderArgs` and `WeaverseComponentSchema`; the root `@weaverse/hydrogen` entry only exports `createSchema()`, data helpers and types.
> `@weaverse/hydrogen` 5.x (Hydrogen 2026.4 and earlier) imports everything from `@weaverse/hydrogen` and uses `HydrogenComponentProps`, `ComponentLoaderArgs` and `HydrogenComponentSchema`. On a 5.x project, convert samples to these names. Upgrade to 6 only when asked (`npx @weaverse/cli@latest migrate v6`, plus the Hydrogen 2026.10 upgrade). Do not mix major versions.
> Next.js themes use `@weaverse/hydrogen` 6.2.0 or later: import client and shared code from `@weaverse/hydrogen/next` and server-only code from `@weaverse/hydrogen/next/server`. `@weaverse/next` is deprecated; never install or import it.
> For live project data (pages, theme settings, translations), use the Weaverse MCP server: https://weaverse.io/docs/developer-tools/weaverse-mcp

# Customer Account API Local Development

> How to set up and test Shopify Customer Account API locally in your Weaverse Hydrogen storefront — for both paid stores and development stores.

# Customer Account API Local Development

> [!NOTE]
>
> This guide is for Shopify Hydrogen storefronts. Building on Next.js? See the [Next.js overview](https://weaverse.io/docs/nextjs/overview.md).

The Customer Account API requires OAuth 2.0 flows with HTTPS callback URLs — which means `http://localhost` won't work. Hydrogen 2026.10 refuses to build a login URL over plain HTTP, so `/account/login` fails under `npm run dev` by design. This guide walks you through running the Pilot theme locally with full Customer Account API support.

> [!WARNING]
>
> The setup differs depending on your **store type**:
>
> * **Paid stores** (Basic, Shopify, Advanced, Plus) → use the built-in `dev:https` command, which serves the dev server over HTTPS and registers its URLs for you
> * **Development stores** (Partner/Staff) → use ngrok or Cloudflare Tunnel with manual OAuth configuration in the Headless sales channel app

## How Sign-In Works

* Hydrogen 2026.10 owns the fixed, unprefixed routes `/account/login`, `/account/authorize`, `/account/refresh` and `/account/logout`, registered in `server.ts` with `createCustomerAccountServerHandlers()`. Link to them with a plain `<a>` or `<form>`, never React Router's `<Link>` or `<Form>`: they answer with a redirect that client-side routing cannot follow.
* The market travels in the query string. An account page visited without a session redirects to `/account/login?return_to=/de-de/account&locale=de`, so the shopper signs in on Shopify's German login page and comes back to the German market.
* The customer's tokens live in the signed session cookie (`SESSION_SECRET`).

See [Step 11 of the v6 migration guide](https://weaverse.io/docs/migration-advanced/v6-migration.md#step-11-move-customer-accounts-to-hydrogens-handlers) for the server code.

## Prerequisites

* A Shopify store with the **Hydrogen** or **Headless** sales channel installed
* Customer accounts enabled in your Shopify admin
* Shopify CLI installed (`@shopify/cli` 4.4.0 or later, with `@shopify/cli-hydrogen` 13.0.4 or later so the dev server can register its URLs for you)
* Your Hydrogen project linked to your store (`shopify hydrogen link`)

***

## Step 1: Enable Customer Accounts

1. From your Shopify admin, go to **Settings > Customer accounts**
2. Under **Accounts in online store and checkout**, click **Edit**
3. Select **Customer accounts**
4. Click **Save**

***

## Step 2: Link Your Project

If you have an existing `.shopify/project.json` pointing to a different store, delete it first:

```bash theme={null}
rm .shopify/project.json
```

Then link to the correct store:

```bash theme={null}
shopify hydrogen link
```

> [!WARNING]
>
> If `.shopify/project.json` points to a store where your account lacks Hydrogen/Headless channel access, all `shopify hydrogen` commands will fail with `ACCESS_DENIED` — including `shopify hydrogen link` itself.

***

## Step 3: Pull Environment Variables

```bash theme={null}
shopify hydrogen env pull
```

Verify your `.env` has these variables:

```env theme={null}
SESSION_SECRET="any-long-random-string"
PUBLIC_CUSTOMER_ACCOUNT_API_CLIENT_ID=shp_xxxxx
PUBLIC_STOREFRONT_API_TOKEN="your-storefront-api-token"
PUBLIC_STORE_DOMAIN="your-store.myshopify.com"
SHOP_ID=your-numeric-shop-id
```

`SHOP_ID` is the numeric shop ID, not a GID or domain. Leave `SHOP_ID` and `PUBLIC_CUSTOMER_ACCOUNT_API_CLIENT_ID` empty to run the storefront without customer accounts.

> [!TIP]
>
> When deploying to **Shopify Oxygen**, these variables are injected automatically — no manual setup needed for production.

***

## Option A: Paid Stores (Basic to Plus)

For stores on a paid Shopify plan, use the built-in `dev:https` command. This is the easiest approach — it serves the dev server over HTTPS and configures OAuth automatically.

> [!NOTE]
>
> The `dev:https` script is already configured in the Pilot theme's [`package.json`](https://github.com/Weaverse/pilot/blob/main/package.json) — no additional setup needed.

### Start the HTTPS dev server

```bash theme={null}
npm run dev:https
```

This runs the same `vite dev --port 3456` as `npm run dev`, with Hydrogen's `localHttps` Vite plugin turned on in `vite.config.ts`:

```ts theme={null}
import { localHttps } from "@shopify/hydrogen/vite";

plugins: [
  localHttps({ enabled: process.env.npm_lifecycle_event === "dev:https" }),
  // ...
],
```

The plugin does two things:

1. **Serves HTTPS locally** — at `https://local.tryhydrogen.dev:3456`, a Shopify-owned name that resolves to `127.0.0.1`, with a locally trusted certificate. On the first run it installs a local certificate authority, which may prompt for your password. To do that ahead of time, run `npx hydrogen certs install`.
2. **Syncs OAuth credentials** — uses Shopify CLI to add the Callback URI, JavaScript Origin, and Logout URI to your storefront's Customer Account API settings. The Logout URI it adds is the origin only: add `https://local.tryhydrogen.dev:3456/account/signed-out` yourself, as in the table below

### Open the HTTPS URL

Open the HTTPS URL the dev server prints, for example `https://local.tryhydrogen.dev:3456`, and navigate to `/account` to test login.

If Shopify CLI is missing, outdated or the push fails, the dev server keeps running and prints the values. Set them manually in **Hydrogen > Storefront > Customer Account API settings**:

| Field | Value |
| - | - |
| **Callback URI(s)** | `https://local.tryhydrogen.dev:3456/account/authorize` |
| **JavaScript origin(s)** | `https://local.tryhydrogen.dev` (no port: Shopify rejects origins with a port) |
| **Logout URI(s)** | `https://local.tryhydrogen.dev:3456/account/signed-out` |

Every sign-out returns through `/account/signed-out`, which redirects the shopper to the home page of the market they were browsing, so this one Logout URI covers every market.

> [!WARNING]
>
> Do **not** use `http://localhost:3456` for customer account testing — OAuth redirects will fail on non-HTTPS origins.

***

## Option B: Development Stores — Manual Tunnel Setup

For **Shopify development stores** (Partner/Staff), the automatic Customer Account API setup is not available. You must use a third-party tunneling service and manually configure the Customer Account API in the **Headless** sales channel app.

### Set up a tunnel

Choose either ngrok or Cloudflare Tunnel:

> [tab] ngrok
>
> ```bash theme={null}
> # Install ngrok
> brew install ngrok
>
> # Start a tunnel to your dev server
> ngrok http 3456
> ```
>
> > [!TIP]
> >
> > Use a [static ngrok domain](https://ngrok.com/blog-post/free-static-domains-ngrok-users) so you don't have to reconfigure OAuth settings every time you restart.

> [tab] Cloudflare Tunnel
>
> ```bash theme={null}
> # Install cloudflared
> brew install cloudflare/cloudflare/cloudflared
>
> # Start a quick tunnel
> cloudflared tunnel --url http://localhost:3456
> ```
>
> Note: Quick tunnels generate a random URL each time. Use a [named tunnel](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/get-started/create-local-tunnel/) for a stable URL.

### Configure Customer Account API

For development stores, configure this in the **Headless** sales channel app:

1. Open your Shopify admin → **Settings > Customer accounts**
2. Find **Customer Account API** and open **Application setup**
3. Ensure the client type is set to **Public**
4. Update the following fields with your tunnel URL:

| Field | Value |
| - | - |
| **Callback URI(s)** | `https://your-tunnel-domain/account/authorize` |
| **JavaScript origin(s)** | `https://your-tunnel-domain` |
| **Logout URI** | `https://your-tunnel-domain/account/signed-out` |

### Update Content Security Policy

In `app/weaverse/csp.ts`, add the tunnel domain to `connectSrc`:

```ts theme={null}
connectSrc: [
  "https://your-tunnel-domain",
  "vimeo.com",
  // ... other sources
],
```

See [Content Security Policy](https://weaverse.io/docs/features/content-security.md) for how these directives become the header.

### Start the dev server

```bash theme={null}
npm run dev
```

Then access your storefront via the tunnel URL (not localhost). Pilot honors the tunnel's `x-forwarded-proto: https` header, so the login URL uses HTTPS.

***

## Account Routes in Pilot Theme

Login, OAuth callback, token refresh and logout are handled by Hydrogen's Customer Account handlers at `/account/login`, `/account/authorize`, `/account/refresh` and `/account/logout`, not by route files. The Pilot theme includes the account pages at `app/routes/account/`:

| Route | Purpose |
| - | - |
| `dashboard/index.tsx` | Account dashboard |
| `dashboard/account-details.tsx` | Customer profile details |
| `dashboard/address-book.tsx` | Saved addresses |
| `dashboard/orders-history.tsx` | Order history |
| `profile.tsx` | Edit profile |
| `edit.tsx` | Edit account settings |
| `orders/list.tsx` | Orders list |
| `orders/order.tsx` | Single order view |
| `address/index.tsx` | Address management |
| `address/list.tsx` | Address list |

Source: [Pilot theme routes](https://github.com/Weaverse/pilot/tree/main/app/routes/account)

> [!NOTE]
>
> Customer account pages are **code-based routes** — they are not editable through Weaverse Studio's visual editor. Any layout or design changes need to be done directly in the route files.

***

## Troubleshooting

> [accordion] Login fails or redirect loop on localhost
>
> Customer Account API requires HTTPS. Use `npm run dev:https` (paid stores) or set up a tunnel (dev stores). Never test account flows on `http://localhost`. An error like `Customer Account OAuth origin must use HTTPS` means you opened the site over `http://`.

> [accordion] ACCESS\_DENIED error on shopify hydrogen commands
>
> Your `.shopify/project.json` is pointing to a store where you don't have channel access. Delete it and re-link:
>
> ```bash theme={null}
> rm .shopify/project.json
> shopify hydrogen link
> ```

> [accordion] OAuth redirect mismatch error
>
> The Callback URI, JavaScript origin and Logout URI in your Shopify admin must exactly match the URL you are browsing, including the port (except the JavaScript origin, which has none). For paid stores using `dev:https`, this is synced automatically. For dev stores, update it manually. A sign-in that lands on `/account?login=failed` or loops back to Shopify usually has a mismatch here.

> [accordion] Customer data not persisting after login
>
> The customer's tokens are stored in the session cookie, which `server.ts` must commit on every response path, including the responses of `handleShopifyRoutes`. Check that `SESSION_SECRET` is set and that your server entry commits the session as in [Step 3 of the v6 migration guide](https://weaverse.io/docs/migration-advanced/v6-migration.md#step-3-own-the-request-lifecycle-in-the-server-entry).

> [accordion] Port already in use
>
> The dev server uses port `3456` and exits when the port is taken. To free it:
>
> ```bash theme={null}
> lsof -ti:3456 | xargs kill
> ```

***

## Next Steps

* Read the [Customer Account API reference](https://shopify.dev/docs/api/customer) for available queries and mutations
* Follow Shopify's [Using Customer Account API with Hydrogen](https://shopify.dev/docs/storefronts/headless/building-with-the-customer-account-api/hydrogen) tutorial
* Learn about [Weaverse environment variables](https://weaverse.io/docs/development-guide/environment-setup.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.