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

@erpspace/auth-context

v0.1.6

Published

Supabase authentication context and UI components for React applications

Readme

@erpspace/auth-context

Supabase authentication context and UI components for React applications.

Project Setup

1. Create a new React project with TypeScript (Vite)

npm create vite@latest my-app -- --template react-ts
cd my-app
npm install

2. Install and configure shadcn/ui

npx shadcn@latest init

Follow the prompts to configure shadcn with your preferred settings.

3. Install @erpspace/auth-context

npm install @erpspace/auth-context

Usage

Basic Setup

Wrap your application with AppContext:

import { AppContext, ProtectedRoute, Spinner } from '@erpspace/auth-context'

function Skeleton() {
  return (
    <div className="min-h-screen w-full flex items-center justify-center">
      <Spinner />
    </div>
  )
}

function App() {
  return (
    <AppContext skeleton={<Skeleton />}>
      <ProtectedRoute>
        {/* Your app content */}
      </ProtectedRoute>
    </AppContext>
  )
}

Configuration

Production

On production, the package automatically fetches configuration from your API at api.{domain}/config. The expected response format:

{
  "SUPABASE_URL": "https://your-project.supabase.co",
  "SUPABASE_KEY": "your-anon-key",
  "SESSION_DOMAIN": ".yourdomain.com",
  "DEFAULT_SUBDOMAIN": "app"
}

Development (using .env)

During development, create a .env file in your project root:

VITE_SUPABASE_URL=https://your-project.supabase.co
VITE_SUPABASE_KEY=your-anon-key
VITE_SESSION_DOMAIN=localhost

Important: Add .env to your .gitignore:

# Environment variables
.env
.env.local
.env.*.local

Then configure the AppContext to use these environment variables as fallback:

function App() {
  return (
    <AppContext 
      skeleton={<Skeleton />}
      fallbackConfig={{
        SUPABASE_URL: import.meta.env.VITE_SUPABASE_URL,
        SUPABASE_KEY: import.meta.env.VITE_SUPABASE_KEY,
        SESSION_DOMAIN: import.meta.env.VITE_SESSION_DOMAIN || 'localhost',
      }}
    >
      <ProtectedRoute>
        {/* Your app content */}
      </ProtectedRoute>
    </AppContext>
  )
}

Custom API URL

<AppContext 
  skeleton={<Skeleton />}
  apiUrl="https://api.example.com"
>
  {/* ... */}
</AppContext>

Hooks

import { useConfig, useUser } from '@erpspace/auth-context'

function MyComponent() {
  const config = useConfig()
  const user = useUser()

  return (
    <div>
      <p>Logged in as: {user?.email}</p>
      <p>Using Supabase: {config.SUPABASE_URL}</p>
    </div>
  )
}

Using Individual Contexts

If you need more control, you can use the providers separately:

import { 
  ConfigProvider, 
  UserContextProvider, 
  ProtectedRoute,
  Toaster 
} from '@erpspace/auth-context'

function App() {
  return (
    <ConfigProvider skeleton={<Skeleton />}>
      <UserContextProvider skeleton={<Skeleton />}>
        <ProtectedRoute>
          {/* Your app content */}
        </ProtectedRoute>
      </UserContextProvider>
      <Toaster />
    </ConfigProvider>
  )
}

License

MIT