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

react-access-kit

v0.0.2

Published

Secure, customizable React access-control wrapper with roles, passwords, and auto-lock.

Readme

react-access-kit

A secure, customizable React access-control wrapper. Protect pages or components with passwords and roles, with optional auto-lock and persistent storage.

🔒 You can even rotate/change keys to invalidate old sessions.


Features

  • Role-based access control (admin, viewer, etc.)
  • Password-protected wrapper component (<AccessGate>)
  • Optional persistent storage (encrypted in localStorage)
  • Timeout auto-lock per role
  • Fully customizable prompt UI with <PasswordPrompt> or your own component
  • Optional secretKey to rotate/change keys for security

Installation

npm install react-access-kit
# or
yarn add react-access-kit

Basic Usage

import React from "react";
import { AccessGate, PasswordPrompt } from "react-access-kit";

export default function App() {
  return (
    <AccessGate
      roles={{ admin: "1234", viewer: "abcd" }}
      role="admin"
      timeoutMinutes={5}
      secretKey="my-custom-key"
      renderPrompt={({ role, onSubmit, error }) => (
        <PasswordPrompt
          role={role}
          onSubmit={onSubmit}
          error={error}
          title="Admin Login"
        />
      )}
    >
      <h1>Secret Admin Area 🚀</h1>
      <p>Only visible if you know the password.</p>
    </AccessGate>
  );
}

AccessGate Props

| Prop | Type | Default | Description | | ---------------- | ---------------------- | ------------------ | --------------------------------------- | | roles | Record<string, string> | required | Role-password map ({ admin: "1234" }) | | role | string | required | Current role to check | | title | string | "Enter Password" | Default title for password prompt | | persist | boolean | true | Store unlocked roles in localStorage | | secretKey | string | optional | Custom encryption key for storage | | timeoutMinutes | number | optional | Auto-lock after X minutes | | onSuccess | () => void | optional | Callback when unlock succeeds | | renderPrompt | function | optional | Render custom password prompt |


useAccess Hook

const { unlockedRoles, hasAccess, unlock, lock, loading } = useAccess({
  roles: { admin: "1234" },
  persist: true,
  secretKey: "my-key",
  timeoutMinutes: 5,
});
  • unlockedRoles: array of unlocked roles
  • hasAccess(role): boolean if role is unlocked
  • unlock(role, password): try to unlock role
  • lock(role?): lock one or all roles
  • loading: boolean, true while restoring state from storage

PasswordPrompt Component

Simple default password form; can be used standalone or via renderPrompt:

<PasswordPrompt
  role="admin"
  onSubmit={(password) => unlock("admin", password)}
  title="Enter Admin Password"
  error="Invalid password"
/>

Props:

  • role: string, role name
  • onSubmit: (password: string) => void
  • title: string
  • placeholder: string
  • buttonLabel: string
  • error: string
  • style: React.CSSProperties

Notes

  • Rotation / changing keys: Use secretKey to rotate/change encryption keys. Old sessions will automatically be invalidated.
  • Works in static hosting (Netlify, GitHub Pages, Vercel).
  • Fully customizable UI via renderPrompt or <PasswordPrompt>.

Example: Custom Prompt

<AccessGate
  roles={{ admin: "1234" }}
  role="admin"
  renderPrompt={({ role, onSubmit, error }) => (
    <div style={{ padding: 20, border: "1px solid red" }}>
      <h2>{role} Login</h2>
      {error && <p>{error}</p>}
      <input type="password" onChange={(e) => onSubmit(e.target.value)} />
    </div>
  )}
>
  <h1>Protected Content</h1>
</AccessGate>