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

@asteby/metacore-auth

v7.0.0

Published

Metacore auth kit — Zustand store, API client factory, login/signup/forgot pages, guards for TanStack Router

Readme

@asteby/metacore-auth

Metacore auth kit: Zustand store, createApiClient factory, TanStack Router guard builder, and brand-less sign-in / sign-up / forgot-password / OTP pages.

Install

pnpm add @asteby/metacore-auth @asteby/metacore-ui zustand @tanstack/react-router

Peer deps required: react, react-dom, @tanstack/react-router, zustand.

Entry points

| Import path | Exports | | ----------------------------------- | ------------------------------------------------------------ | | @asteby/metacore-auth | Everything below (re-exported). | | @asteby/metacore-auth/store | useAuthStore, AuthUser, AuthState, AUTH_STORAGE_KEYS | | @asteby/metacore-auth/provider | AuthProvider, useAuth | | @asteby/metacore-auth/api-client | createApiClient, ApiClient | | @asteby/metacore-auth/guards | createAuthGuard | | @asteby/metacore-auth/pages | SignInPage, SignUpPage, ForgotPasswordPage, OtpPage, AuthLayout | | @asteby/metacore-auth/components | PasswordInput, SignOutDialog |

Quickstart

1. Create the API client (once, at boot)

import { createApiClient, useAuthStore } from '@asteby/metacore-auth'
import i18n from './i18n'

export const api = createApiClient({
  baseURL: import.meta.env.VITE_API_URL ?? '/api',
  getToken: () => useAuthStore.getState().auth.accessToken,
  getLanguage: () => i18n.language,
  getBranchId: () => {
    try {
      const branch = JSON.parse(localStorage.getItem('current_branch') || '{}')
      return branch?.id
    } catch {
      return null
    }
  },
  onUnauthorized: () => {
    useAuthStore.getState().auth.reset()
    window.location.href = '/sign-in'
  },
})

2. Guard authenticated routes

// src/routes/_authenticated/route.tsx
import { createFileRoute } from '@tanstack/react-router'
import { createAuthGuard } from '@asteby/metacore-auth/guards'
import { AuthenticatedLayout } from '@/components/layout/authenticated-layout'

export const Route = createFileRoute('/_authenticated')({
  beforeLoad: createAuthGuard(),
  component: AuthenticatedLayout,
})

3. Render branded sign-in

import { SignInPage } from '@asteby/metacore-auth/pages'
import { useAuthStore } from '@asteby/metacore-auth/store'
import { useNavigate, Link } from '@tanstack/react-router'
import { Logo } from '@/assets/logo'
import { api } from '@/lib/api'

export function SignInRoute() {
  const navigate = useNavigate()
  const { auth } = useAuthStore()
  return (
    <SignInPage
      brandName='MyApp'
      logo={<Logo className='size-7' />}
      showcase={<MyErpShowcase />}
      forgotPasswordSlot={<Link to='/forgot-password'>¿Olvidaste tu contraseña?</Link>}
      onSubmit={async ({ email, password, redirectTo }) => {
        const { data } = await api.post('/auth/login', { email, password })
        auth.setUser(data.data.user)
        auth.setAccessToken(data.data.token)
        navigate({ to: redirectTo || '/' })
      }}
    />
  )
}

Design notes

  • Zustand store is canonical — generic shape (user + token + reset) shared across host applications. Persists to localStorage keys auth_token / auth_user.
  • Factory, not singletoncreateApiClient avoids baking env vars into the library. The host app wires token / language / branch getters.
  • Pages are brand-less — accept brandName, logo, showcase, headerSlot, footerSlot so each app supplies its own identity.
  • onSubmit delegated — pages don't assume endpoints, toasts, or navigation. The caller owns the network layer.