Customer Account API Local Development
The Customer Account API requires OAuth 2.0 flows with HTTPS callback URLs — which meanshttp://localhost won’t work. This guide walks you through running the Pilot theme locally with full Customer Account API support.
Prerequisites
- A Shopify store with the Hydrogen or Headless sales channel installed
- Customer accounts enabled in your Shopify admin
- Shopify CLI installed (
@shopify/cli) - Your Hydrogen project linked to your store (
shopify hydrogen link)
Step 1: Enable Customer Accounts
- From your Shopify admin, go to Settings > Customer accounts
- Under Accounts in online store and checkout, click Edit
- Select Customer accounts
- Click Save
Step 2: Link Your Project
If you have an existing.shopify/project.json pointing to a different store, delete it first:
Step 3: Pull Environment Variables
.env has these variables:
Option A: Paid Stores (Basic to Plus)
For stores on a paid Shopify plan, use the built-indev:ca command. This is the easiest approach — it handles tunneling and OAuth configuration automatically.
The
dev:ca script is already configured in the Pilot theme’s package.json — no additional setup needed.Start the dev server
--customer-account-push flag does two things:
- Creates an HTTPS tunnel — publishes your local dev server to a
*.tryhydrogen.devdomain - Syncs OAuth credentials — automatically configures the Callback URI, JavaScript Origin, and Logout URI in your Shopify admin
Open the tunnel URL
After the dev server starts, look for the tunnel URL in your terminal:*.tryhydrogen.dev URL to test customer account flows. Navigate to /account to test login.
Option B: Development Stores — Manual Tunnel Setup
For Shopify development stores (Partner/Staff), the--customer-account-push flag 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:- ngrok
- Cloudflare Tunnel
Configure Customer Account API
For development stores, configure this in the Headless sales channel app:- Open your Shopify admin → Settings > Customer accounts
- Find Customer Account API and open Application setup
- Ensure the client type is set to Public
- 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 |
Update Content Security Policy
In yourapp/entry.server.tsx, add the tunnel domain to your CSP:
Start the dev server
Account Routes in Pilot Theme
The Pilot theme includes a complete set of customer account routes atapp/routes/account/:
| Route | Purpose |
|---|---|
auth/login.ts | Redirects to Shopify login |
auth/logout.ts | Logs the customer out |
auth/authorize.ts | Handles OAuth callback |
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 |
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
Login fails or redirect loop on localhost
Login fails or redirect loop on localhost
Customer Account API requires HTTPS. Use
npm run dev:ca (paid stores) or set up a tunnel (dev stores). Never test account flows on http://localhost.ACCESS_DENIED error on shopify hydrogen commands
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:OAuth redirect mismatch error
OAuth redirect mismatch error
The Callback URI in your Shopify admin must exactly match your tunnel URL (including no trailing slash). For paid stores using
--customer-account-push, this is synced automatically. For dev stores, update it manually.Customer data not persisting after login
Customer data not persisting after login
Ensure you commit the session at the end of any loader/action with a customer auth check:
Port already in use
Port already in use
The dev server defaults to port
3456. To free it:Next Steps
- Read the Customer Account API reference for available queries and mutations
- Follow Shopify’s Using Customer Account API with Hydrogen tutorial
- Learn about Weaverse environment variables