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

@govector/auth

v0.1.7

Published

Authentication components and hooks for Vector-generated apps

Downloads

519

Readme

@govector/auth

React authentication components and hooks for Vector-generated apps. Handles login/signup via Vector's hosted auth proxy with JWT-based session management.

Install

npm install @govector/auth

Setup

Wrap your app with VectorAuthProvider:

import { VectorAuthProvider } from "@govector/auth";

function App() {
  return (
    <VectorAuthProvider
      config={{
        authProxyUrl: import.meta.env.VITE_AUTH_PROXY_URL,
        appId: import.meta.env.VITE_APP_ID,
        appVersionId: import.meta.env.VITE_APP_VERSION_ID,
      }}
    >
      <YourApp />
    </VectorAuthProvider>
  );
}

Usage

useAuth hook

import { useAuth } from "@govector/auth";

function Profile() {
  const { isAuthenticated, user, loading, logout, loginUrl, signupUrl } = useAuth();

  if (loading) return <p>Loading...</p>;

  if (!isAuthenticated) {
    return <a href={loginUrl}>Sign in</a>;
  }

  return (
    <div>
      <p>Welcome, {user.full_name}</p>
      <button onClick={logout}>Sign out</button>
    </div>
  );
}

LoginButton / SignupButton

import { LoginButton, SignupButton } from "@govector/auth";

function Landing() {
  return (
    <div>
      <LoginButton label="Sign in" className="btn btn-primary" />
      <SignupButton label="Get started" className="btn btn-secondary" />
    </div>
  );
}

AuthCallback

Add to your router at /auth/callback:

import { AuthCallback } from "@govector/auth";
import { useNavigate } from "react-router-dom";

function AuthCallbackPage() {
  const navigate = useNavigate();

  return (
    <AuthCallback
      onSuccess={() => navigate("/", { replace: true })}
      onError={(error) => console.error(error)}
    />
  );
}

onSuccess fires once the user is fully signed in — i.e. after the token has been exchanged and the session has hydrated via useAuth — so navigating to a protected route from onSuccess is safe.

onError fires for token-exchange failures, a missing token, or a hydration timeout. If the token exchange succeeds but the session does not hydrate within 10 seconds (typically caused by third-party cookies being blocked), onError is called with a hydration-timeout message.

Auth Flow

  1. User clicks LoginButton -> redirects to Vector's hosted login page
  2. User authenticates (Google, magic link, etc.)
  3. Auth proxy redirects to /auth/callback?token=<jwt>
  4. AuthCallback exchanges the JWT for a local session cookie
  5. useAuth detects the session and updates state

API

VectorAuthProvider

| Prop | Type | Description | |---|---|---| | config.authProxyUrl | string | Vector auth proxy URL | | config.appId | string | Your app's ID | | config.appVersionId | string | Your app version ID | | config.apiBaseUrl | string? | Base URL for API calls (default: current origin) |

useAuth() -> AuthState

| Field | Type | Description | |---|---|---| | isAuthenticated | boolean | Whether the user is logged in | | user | AuthUser \| null | Current user object | | loading | boolean | True during initial auth check | | loginUrl | string | URL to redirect for login | | signupUrl | string | URL to redirect for signup | | logout | () => void | Clears session and redirects to / |

AuthUser

| Field | Type | |---|---| | id | string | | email | string | | first_name | string | | last_name | string | | full_name | string | | picture | string |