Multipass in Hydrogen
Multipass lets a Shopify Plus merchant authenticate customers in an external system, then sign them into Shopify without asking for a Shopify password again. In Hydrogen, the recommended implementation is to exchange the Multipass token for a Storefront APICustomerAccessToken, store that access token in the Hydrogen session cookie, then use it for customer profile, order, address, and cart buyer identity calls.
When to use Multipass
Use this guide when the merchant already has an external identity system, for example:- A mobile app or loyalty app authenticates customers first
- An enterprise CRM validates customers by phone/OTP
- Middleware checks or creates the Shopify customer
- The middleware returns a Shopify Multipass token
- Hydrogen needs to complete login without sending the customer through Shopify’s hosted login screen
Requirements
- Shopify Plus store
- Legacy customer accounts selected in Shopify Admin → Settings → Customer accounts
- Multipass enabled in Shopify admin
- Storefront API token with customer access-token permissions
- A server-side middleware or backend that generates Multipass tokens
- A Hydrogen storefront with cookie session support
Architecture
The Multipass token is only an exchange credential. Hydrogen should store the returnedcustomerAccessToken, not the Multipass token.
Multipass token rules
Shopify’s Storefront API mutation has two important constraints:- Multipass tokens are valid for 15 minutes
- Multipass tokens are single-use
Step 1 — Exchange Multipass for a customer access token
Create a server-side route that receives the Multipass token and exchanges it with Shopify. Example route:app/routes/account/multipass.tsx
You can use a
loader instead of an action if your external system redirects to Hydrogen with a token in the URL. Prefer POST when possible so tokens are not stored in browser history, server logs, analytics tools, or referer headers.Step 2 — Read the token from the Hydrogen session
In legacy customer account routes, read the stored token fromcontext.session.
Step 3 — Associate the customer with the cart
After login, update the cart buyer identity with the Storefront API customer token.Step 4 — Logout
Unset the customer access token from the Hydrogen session. If your merchant identity provider also has a session, redirect to its logout endpoint too.Adapting the Pilot theme
The Pilot theme ships with Customer Account API routes by default:/account/loginstarts Shopify’s Customer Account API OAuth flow/account/authorizecompletes the OAuth callback- Account pages query
context.customerAccount
context.storefront.mutate(customerAccessTokenCreateWithMultipass)for logincontext.session.get('customerAccessToken')for session state- Storefront API
customer(customerAccessToken: ...)queries for profile, orders, and addresses context.cart.updateBuyerIdentity({customerAccessToken})for cart association
Domain setup
Multipass does not have a callback-domain setup like Customer Account API OAuth. The domain depends on the implementation:Standard Shopify Multipass redirect
Redirect to the Shopify Online Store / classic account domain:Hydrogen-native Multipass exchange
Redirect or post to your Hydrogen route:customerAccessTokenCreateWithMultipass and sets its own session cookie.
If Liquid and Hydrogen run in parallel, use separate domain targets in Shopify: for example
www.example.com for Hydrogen and checkout.example.com or liquid.example.com for Online Store. Checkout remains Shopify checkout either way.Security checklist
- Keep the Multipass secret only in the merchant backend
- Generate Multipass tokens on demand
- Send tokens to Hydrogen server-side or via short-lived POST only
- Never store the Multipass token in the session
- Store only the returned
customerAccessToken - Use
httpOnly,sameSite: 'lax', and secure session cookies in production - Use
CacheNone()for authenticated customer/account queries - Clear the session when the token is expired or customer lookup fails
- Avoid logging tokens, request bodies, query strings, or GraphQL variables that contain credentials
Troubleshooting
`customerAccessTokenCreateWithMultipass` returns an error
`customerAccessTokenCreateWithMultipass` returns an error
Confirm that Multipass is enabled, the store is on Shopify Plus, the store uses legacy customer accounts, and the token was generated with the correct Multipass secret. Also confirm that the token has not expired or already been used.
Customer logs in but account page still redirects to Shopify login
Customer logs in but account page still redirects to Shopify login
The route is probably still using
context.customerAccount.handleAuthStatus() or context.customerAccount.query(). Multipass requires legacy Storefront API customer-token queries instead.Orders or profile data are empty
Orders or profile data are empty
Check that you are querying Storefront API customer fields with
customer(customerAccessToken: ...), not Customer Account API fields. Also verify the Multipass token uses the same email address as the Shopify customer record.Checkout is not associated with the logged-in customer
Checkout is not associated with the logged-in customer
Call
context.cart.updateBuyerIdentity({customerAccessToken}) after login or before checkout. Use the returned Storefront API customer access token, not the Multipass token.Customer Account API and Multipass both need to work
Customer Account API and Multipass both need to work
Treat this as a custom dual-auth project. The two systems use different session models and account APIs. In most cases, the cleaner approach is to move existing customers into one IdP path using the same email address, or use a pure legacy customer-token flow if Multipass is mandatory.