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-control-kit

v2.0.0

Published

Lightweight TypeScript-first RBAC library for React with zero runtime dependencies

Readme

react-access-control-kit

Lightweight, TypeScript-first access-control library for React 18+ with zero runtime dependencies.

  • RBAC with wildcards and role hierarchy
  • Feature flags
  • ABAC policy engine
  • Async permission loading
  • SSR compatible and tree-shakeable

Installation

npm install react-access-control-kit

Peer dependencies: react and react-dom ≥ 18.

Quick Start

import {
  AccessControlProvider,
  AccessGuard,
  Can,
  Feature,
  Policy,
  usePermission,
  useAccessStatus,
} from "react-access-control-kit";

const policies = {
  editOwnPost: ({ user, resource }) =>
    resource?.authorId === user.attributes.userId,
};

function App() {
  return (
    <AccessControlProvider
      permissions={["posts:*"]}
      roles={["admin"]}
      features={["beta-dashboard"]}
      attributes={{ userId: "u1" }}
      policies={policies}
      roleHierarchy={{ admin: ["manager"], manager: ["user"] }}
    >
      <Dashboard />
    </AccessControlProvider>
  );
}

Async loading

<AccessControlProvider
  loadAccess={async () => {
    const data = await api.getAccess();
    return {
      permissions: data.permissions,
      roles: data.roles,
      features: data.features,
      attributes: { userId: data.id },
    };
  }}
>
  <AppShell />
</AccessControlProvider>;

function AppShell() {
  const { isLoading, isError, error, reload } = useAccessStatus();
  if (isLoading) return <Spinner />;
  if (isError)
    return <button onClick={() => void reload()}>{error?.message}</button>;
  return <Routes />;
}

API overview

Provider props

| Prop | Description | | ----------------------- | ------------------------------------ | | permissions / roles | Sync RBAC grants | | features | Flag list or { flag: boolean } map | | attributes | ABAC subject attributes | | policies | Named policy functions | | roleHierarchy | Role inheritance map | | loadAccess | Async loader for access snapshot |

Hooks

usePermission, useAnyPermission, useAllPermissions, useRole, useAnyRole, useAllRoles, useFeature, useAnyFeature, useAllFeatures, usePolicy, useAttributes, useAccessStatus

Components

  • <Can /> / <Role /> — permission / role gates
  • <Feature /> — feature flag gate
  • <Policy name="…" resource={…} /> — ABAC policy gate
  • <AccessGuard /> — route guard (permissions, roles, features, and/or policy)
<AccessGuard
  permission="billing:view"
  feature="billing-v2"
  policy="engOnly"
  fallback={<Navigate to="/" replace />}
>
  <BillingPage />
</AccessGuard>

Wildcards & hierarchy

  • posts:* matches posts:read, posts:write, …
  • * matches everything
  • roleHierarchy={{ admin: ["manager"] }} expands inherited roles

Policy engine (framework-agnostic)

import {
  createPolicyEngine,
  definePolicy,
  evaluatePolicy,
} from "react-access-control-kit";

const policies = {
  engOnly: definePolicy(({ user }) => user.attributes.department === "eng"),
};

const engine = createPolicyEngine(policies);
engine.evaluate("engOnly", {
  user: {
    permissions: [],
    roles: [],
    features: [],
    attributes: { department: "eng" },
  },
});

Examples

FAQ

SSR? Yes — no browser APIs. Call loadAccess only with data safe for your environment.

Tree-shaking? "sideEffects": false and ESM exports.

Out of scope

  • Multi-tenant helpers
  • DevTools UI
  • Built-in React Router / Next.js adapters (use AccessGuard + your router)

License

MIT