Weaverse LogoWeaverse
All Articles
Paul Phan
3 mins read

How to Add Shopify shopify-account Component to Your Hydrogen Storefront

Add Shopify new shopify-account web component to your Hydrogen storefront. Supports passwordless login, MFA, and new customer accounts.
How to Add Shopify shopify-account Component to Your Hydrogen Storefront
Table of Contents

How to Add Shopify's New <shopify-account> Component to Your Hydrogen Storefront

Shopify just dropped official docs for the <shopify-account> web component — a native way to let customers sign in directly from your Hydrogen storefront without leaving the page.

Implementing the shopify-account component in Hydrogen storefronts
Implementing the shopify-account component in Hydrogen storefronts

If you've ever wrestled with Hydrogen's Customer Account API setup, this is the simplest auth flow you've seen yet.

Account migration planning worksheet and implementation flow
Account migration planning worksheet and implementation flow

What Is the <shopify-account> Component?

It's a Storefront Web Component that handles the full customer sign-in flow. Drop it in your header, pass two tokens, and your customers get a seamless login experience — all without custom auth routes.

Two tokens required:

  • public-access-token → from PUBLIC_STOREFRONT_API_TOKEN in your .env
  • customer-access-token → from the Customer Account API after authentication

Prerequisites

Before you start:

  1. Hydrogen storefront deployed to Oxygen (Getting started guide)
  2. Customer Account API configured (Tutorial here)
  3. Storefront API permissions in Shopify Admin:
    • unauthenticated_read_customers
    • unauthenticated_read_content
    • unauthenticated_read_product_listings

Step 1: Load the Account Component Bundle

The bundle isn't included in the default Hydrogen scaffold. Load it via CDN in /app/root.jsx:

import { Script } from '@shopify/hydrogen';
// Inside <head> of Layout component:
<Script src="https://cdn.shopify.com/storefront/web-components/account.js" />

Step 2: Update /app/root.jsx Loader

Pass both publicAccessToken and customerAccessToken down to child components:

export async function loader({ context }) {
const { storefront, customerAccount } = context;
// Get public storefront token
const publicAccessToken = context.env.PUBLIC_STOREFRONT_API_TOKEN;
// Get customer token (if authenticated)
const customerAccessToken = await customerAccount.getAccessToken();
return defer({
publicAccessToken,
customerAccessToken,
// ...other loader data
});
}

Step 3: Update PageLayout.jsx

Pass the tokens through to your layout and add proper TypeScript types:

// Add to @property JSDoc near bottom of file:
// * @property {string} publicAccessToken
// * @property {string} customerAccessToken

Step 4: Replace the Sign In Button in Header.jsx

Swap the default "Sign In" link for the <shopify-account> component:

function HeaderCtas({ publicAccessToken, customerAccessToken }) {
return (
<nav>
<shopify-account
sign-in-url="/account/login"
public-access-token={publicAccessToken}
customer-access-token={customerAccessToken}
/>
{/* Cart icon, etc. */}
</nav>
);
}

Note: sign-in-url should point to your authorization request page — default is /account/login in Hydrogen.

Step 5: Upgrade for Better Login UX (Hydrogen ≥ 2025.7.3)

If you're on @shopify/hydrogen 2025.7.3+, update /app/routes/account_.login.jsx to use the improved login options:

// Use the new login() options for better UX
const loginUrl = await customerAccount.login({
// Additional options now available
});

Check the full API docs for all available options.

Styling

The component is fully stylable via CSS. Refer to the Storefront Web Components docs for CSS custom properties.

Important: No Localhost Support

The Customer Account API doesn't work on localhost. You'll need to deploy to Oxygen to test:

shopify hydrogen deploy

Test on your production URL after deployment.

Why This Matters for Weaverse Users

If you're building a Weaverse-powered Hydrogen store, this component drops directly into your theme's header section. No custom auth logic needed.

Coming soon: Native <shopify-account> support in Weaverse sections — stay tuned.

TL;DR

StepFileAction
1root.jsxLoad CDN bundle + pass tokens from loader
2PageLayout.jsxThread tokens to child components
3Header.jsxReplace Sign In with <shopify-account>
4account_.login.jsxUpdate if on Hydrogen ≥ 2025.7.3

Official docs: https://shopify.dev/docs/storefronts/headless/bring-your-own-stack/hydrogen-with-account-component

Reactions

Like
Love
Celebrate
Insightful
Cool!
Thinking

Join the Discussion

Never miss an update

Subscribe to get the latest insights, tutorials, and best practices for building high-performance headless stores delivered to your inbox.

Join the community of developers building with Weaverse.