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

@qadi/react

v0.11.0

Published

React integration for @qadi/core — QadiProvider, hooks, Can/Cannot

Readme

@qadi/react

React bindings for @qadi/core. A QadiProvider, hooks, and Can/Cannot gates.

pnpm add @qadi/react @qadi/core effect @effect/atom-react react

What it is, and what it is not

A binding over effect/reactivity, not a state manager of its own. Decisions live in atoms; the React glue is @effect/atom-react's own useAtomValue, read through its RegistryContext (see AGENTS.md §13 and ADR-QD-014 for why this package depends on that library rather than a hand-rolled useSyncExternalStore call). One evaluation is shared by every component asking the same question — the atom family keys structurally, so two separately built but equal policies share one atom.

import type { AuthSubject } from "@qadi/core";
import { EvaluationServicesNone, hasPermission, permission } from "@qadi/core";
import { Can, QadiProvider, makeQadiAtoms } from "@qadi/react";

const canPublish = hasPermission(permission("post", "publish"));

const atoms = makeQadiAtoms(EvaluationServicesNone); // once, at module scope

export const App = ({ currentUser }: { readonly currentUser: AuthSubject | undefined }) => (
  <QadiProvider atoms={atoms} subject={currentUser}>
    <Can policy={canPublish} fallback={<span>Publishing disabled</span>}>
      <button type="button">Publish</button>
    </Can>
  </QadiProvider>
);

A stale decision is not a decision

While a decision is being re-checked, this package reports nothing rather than the previous verdict. For most data staleness is a feature; for authorization it is an over-permission, however brief — the subject has logged out, or their grants were just revoked, and the answer on screen is the old one. Read decisions through outcomeOf, which is the single place that rule lives: it reads a result into one of five outcomes — Pending, Rechecking, Allowed, Denied, Failed — and only Allowed carries an allow. A failed re-check keeps the previous answer too, as previousSuccess, and no outcome has a field for it. currentDecision is its projection, for a caller that wants a settled decision or nothing.

import { DecisionOutcome, outcomeOf, useDecision } from "@qadi/react";
import { hasPermission, permission } from "@qadi/core";

const canEditDoc = hasPermission(permission("doc", "write"));

export const EditButton = () =>
  DecisionOutcome.$match(outcomeOf(useDecision(canEditDoc)), {
    Pending: () => null,
    Rechecking: () => null,
    Failed: () => <span>Could not check your permissions.</span>,
    Allowed: () => <button type="button">Edit</button>,
    Denied: () => null,
  });

Server rendering

"use client" is applied per module, never to the barrel, so dehydrateDecisions stays callable from a React Server Component while the provider and hooks remain client modules. <QadiProvider> server-renders; a policy needing a resolver renders its pending node, which is the correct answer and the reason hydration exists.

Hydrate on the client with hydrateDecisions. A hydrated decision is bound to one subject, and the client's own answer supersedes the server's seed the moment it arrives.

License

MIT