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

@grantry/react

v0.4.1

Published

Grantry for React: sign-in, sign-up, user profile, pricing and checkout components, hooks, and server-side token verification.

Readme

@grantry/react

Grantry for React: a provider that holds the session, hooks that read it, the prebuilt sign-in, sign-up, account and pricing components, and a server entry for checking access tokens and making checkouts.

npm install @grantry/react

Requires React 18 or 19. For a Next.js application install @grantry/nextjs instead; it re-exports everything here and adds auth() and a middleware.

Setup

Wrap the application in the provider with your publishable key (Grantry dashboard, API keys):

import { GrantryProvider } from '@grantry/react';

export function Root() {
  return (
    <GrantryProvider publishableKey={import.meta.env.VITE_GRANTRY_PUBLISHABLE_KEY}>
      <App />
    </GrantryProvider>
  );
}

Components and hooks

import { SignedIn, SignedOut, SignIn, UserButton, useAuth } from '@grantry/react';

function Header() {
  return (
    <>
      <SignedOut>
        <SignIn />
      </SignedOut>
      <SignedIn>
        <UserButton />
      </SignedIn>
    </>
  );
}

function useApi() {
  const { getToken } = useAuth();
  return async (path: string) =>
    fetch(path, { headers: { authorization: `Bearer ${await getToken()}` } });
}

Also exported: SignUp, UserProfile, PricingTable, CheckoutButton, ProductCard, Protect, SignOutButton, the headless useSignInFlow and useSignUpFlow for your own markup, and useUser, useSession, useAccounts, useOAuth, useEntitlements, usePlans and useReverification. Every element carries a stable gr- class, and the appearance prop styles the same elements from JavaScript.

Selling

<PricingTable>, <ProductCard> and <CheckoutButton> sell through Grantry's hosted checkout: a press makes a checkout for the signed-in user (a signed-out buyer is sent to sign in first) and the browser leaves for the page on your application's checkout domain, coming back to successUrl (this page when left out) once it is paid. onSubscribed and onComplete run on the way back when no successUrl is given. <UserProfile>'s billing tab changes plans and replaces the card the same way. From your own code, useGrantry().redirectToCheckout({ items: [{ priceId }] }) does what the buttons do.

Since 0.2.0 this is the only checkout: the in-app checkout dialog and its card field are gone, with the appearance elements and localization keys only they used.

On your server

import { authenticateRequest } from '@grantry/react/server';

export async function handler(request: Request) {
  const auth = await authenticateRequest(request);
  if (!auth) return new Response('Unauthorized', { status: 401 });
  if (!auth.has({ feature: 'export' })) return new Response('Upgrade required', { status: 403 });
  return Response.json({ userId: auth.userId });
}

@grantry/react/server imports no React and nothing from the browser; it runs on Node 18.18+, Bun, Deno and edge runtimes. verifyToken checks the RS256 signature against Grantry's published keys (fetched once and cached), the issuer, the expiry, and that the token belongs to your application, read from GRANTRY_PUBLISHABLE_KEY (or publishableKey). With no key configured it throws no_audience rather than accept a token minted for another application. clockTolerance allows 30 seconds of clock disagreement by default.

verifyReverification spends a "Verify it's you" grant with your secret key (GRANTRY_SECRET_KEY) before a sensitive action.

createCheckoutSession({ userId, items, successUrl }) makes a hosted checkout for one of your users with the same secret key; redirect to the url it answers with. Take userId from a verified token or your own records, never from the request body, and never log the url: it carries the checkout's key.

Documentation

https://grantry.dev

License

MIT