npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@pradip1995/commerce-auth

v4.0.0

Published

Medusa storefront authentication — login, register, OTP, Google OAuth

Readme

@pradip1995/commerce-auth

Authentication UI and server actions: login, register, OTP, Google OAuth.

import {
  Login,
  LOGIN_VIEW,
  GoogleLoginButton,
  GoogleCallbackPage,
  GoogleAuthShell,
  GoogleIdentityServicesScript,
} from "@pradip1995/commerce-auth"

Google OAuth (redirect flow)

Use GoogleLoginButton for a "Continue with Google" CTA (login, register, modals):

import { GoogleLoginButton } from "@pradip1995/commerce-auth"
import { initiateGoogleAuth } from "@core/data/customer"

<GoogleLoginButton countryCode={countryCode} initiateAuth={initiateGoogleAuth} />

Wire the OAuth callback route:

import { GoogleCallbackPage } from "@pradip1995/commerce-auth"
import { handleGoogleAuthCallback, handleGoogleCallback } from "@core/data/customer"

export default function GoogleCallbackRoute() {
  return (
    <GoogleCallbackPage
      handleAuthCallback={handleGoogleAuthCallback}
      handleCustomerCallback={handleGoogleCallback}
    />
  )
}

Google One Tap (GIS SDK — corner popup)

Uses the official Google Identity Services SDK (accounts.google.com/gsi/client):

  1. google.accounts.id.initialize({ client_id, callback })
  2. google.accounts.id.prompt() — shows the account picker on any page
  3. User clicks an account → JWT credential sent to your backend
  4. Medusa verifies the token via @medusajs/auth-google

Google Cloud Console

  • OAuth 2.0 Client ID (Web application)
  • Authorized JavaScript origins: http://localhost:8000, your production domain
  • OAuth consent screen with app name and branding (controls "Sign in to … with Google")

Root layout

import { retrieveCustomer } from "@core/data/customer"
import {
  GoogleAuthShell,
  GoogleIdentityServicesScript,
} from "@pradip1995/commerce-auth"

export default async function RootLayout({ children }) {
  const customer = await retrieveCustomer().catch(() => null)
  const isAuthenticated = Boolean(customer && customer.id !== "pending_deletion")

  return (
    <html>
      <head>
        {/* Step 2: Load GIS library (official docs) */}
        <GoogleIdentityServicesScript />
      </head>
      <body>
        {/* Step 3: Initialize + prompt on every page for signed-out users */}
        <GoogleAuthShell isAuthenticated={isAuthenticated}>
          {children}
        </GoogleAuthShell>
      </body>
    </html>
  )
}

Set NEXT_PUBLIC_GOOGLE_CLIENT_ID (same client ID as Medusa GOOGLE_CLIENT_ID).

Backend: authenticateGoogleCredential POSTs the JWT to Medusa /auth/customer/google/callback with { credential }. Medusa validates signature, aud, and issuer before creating a session.

Optional: autoSelectReturningUsers on GoogleAuthShell enables GIS auto_select for users who already granted consent.

Consuming apps must provide @modules/* shims for icons and modals, or replace theme slots to wrap headless exports.