This is NOT an official Shopify implementation, use at your own risk
At the time of writing multipass is available for Shopify Plus customers only.
Demonstrates how to persist the user session between Hydrogen and the checkout.
- Add env variables
- Add the MulitpassCheckoutButton to
/app/components/MultipassCheckoutButton.tsx
- Add the multipass.tsx helper to
/lib/multipass/multipass.tsx
- Add the Multipassify class to
/lib/multipass/multipassify.server.tsx
- Add the multipass token generation route to
app/routes/($lang)/account/__public/login.multipass.tsx
- Implement the
<MulitpassCheckoutButton />
in the<Cart />
component atapp/components/Cart.tsx
- Login via
/account/login
- Add any product to the cart
- Click checkout. The MultipassCheckoutButton runs the multipass helper
- The
multipass
helper makes a POST request to the multipass route/account/login/multipass
to generate a token for the currentcustomer
and thetarget url
in this casecart.checkoutUrl
- With the token, the
multipass
helper then redirects to the${PRIVATE_SHOPIFY_CHECKOUT_DOMAIN}/account/login/multipass/token
for token authentication. If successful, the user is authenticated and redirected to thecheckoutUrl
otherwise the user is still redirected but it is not authenticated.
The /account/login-google
route demonstrates loginng with a 3rd-Party auth provider (Google Sign in) and Shopify multipass.
- Add env variables
- Add the GoogleSingInButton to
app/components/GoogleLoginButton.tsx
- Add the multipass.tsx helper to
/lib/multipass/multipass.tsx
- Add the Multipassify class to
/lib/multipass/multipassify.server.tsx
- Add the multipass token generation route to
app/routes/($lang)/account/__public/login.multipass.tsx
- Add the multipass token validation route to
app/routes/(%24lang)/account/__public/login.multipass.%24token.tsx
- Implement the
<GoogleSignIn />
in the google sign in login route (or/app/routes/account/login
)app/components/Cart.tsx
- Login via
/account/login-google/
- The triggers the google auth flow
- Using the return google user data we trigger the multipass helper to automatically create (if the customer does not exist in Shopify) or login (if it exists) via multipass
- The
multipass
helper makes a POST request to the route/account/login/multipass
to generate a token for the currentcustomer
and thetarget url
in this case/account
- The helper redirects to the local multipass validator
/account/login/multipass/token
which persists the user session upon successful validation and redirects to the target url/account
.
PRIVATE_SHOPIFY_STORE_MULTIPASS_SECRET=64 chars (Shopify Plus only)
PUBLIC_STORE_DOMAIN=your-store.myshopify.com
PRIVATE_SHOPIFY_CHECKOUT_DOMAIN=checkout.your-store.com (e.g if configured, otherwise repeat your-store.myshopify.com)
PUBLIC_GOOGLE_CLIENT_ID=xyz123.apps.googleusercontent.com
Hydrogen is Shopify’s stack for headless commerce. Hydrogen is designed to dovetail with Remix, Shopify’s full stack web framework. This template contains a full-featured setup of components, queries and tooling to get started with Hydrogen.
Check out Hydrogen docs Get familiar with Remix
- Remix
- Hydrogen
- Oxygen
- Shopify CLI
- ESLint
- Prettier
- GraphQL generator
- TypeScript and JavaScript flavors
- Tailwind CSS (via PostCSS)
- Full-featured setup of components and routes
Requirements:
- Node.js version 16.14.0 or higher
npm create @shopify/hydrogen@latest --template demo-store
Remember to update .env
with your shop's domain and Storefront API token!
npm run build
npm run dev