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

@permi/react

v0.0.12

Published

React SDK for Permi OAuth2 + PKCE authentication and token management

Readme

@permi/react

React SDK for Permi - OAuth2 + PKCE authentication and wallet management hooks for React applications.

Installation

npm install @permi/react @tanstack/react-query react react-dom
# or
pnpm add @permi/react @tanstack/react-query react react-dom
# or
yarn add @permi/react @tanstack/react-query react react-dom

Peer Dependencies

This package requires:

  • react ^18.0.0
  • react-dom ^18.0.0
  • @tanstack/react-query ^5.0.0

Usage

Setup

Wrap your application with the PermiProvider:

import { PermiProvider } from "@permi/react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";

const queryClient = new QueryClient();

function App() {
  return (
    <QueryClientProvider client={queryClient}>
      <PermiProvider
        baseUrl="https://permi.xyz"
        clientId="your-client-id"
        redirectUri="http://localhost:3000/callback"
      >
        <YourApp />
      </PermiProvider>
    </QueryClientProvider>
  );
}

Authentication

Use the useAuth hook to handle authentication:

import { useAuth } from "@permi/react";

function LoginButton() {
  const { isAuthenticated, isLoading, login, logout } = useAuth();

  if (isLoading) return <div>Loading...</div>;

  if (isAuthenticated) {
    return <button onClick={logout}>Logout</button>;
  }

  return <button onClick={login}>Login</button>;
}

Wallet Hooks

Get Wallet Address

import { useAddress } from "@permi/react";

function WalletAddress() {
  const { data: address, isLoading, error } = useAddress();

  if (isLoading) return <div>Loading...</div>;
  if (error) return <div>Error: {error.message}</div>;

  return <div>Address: {address}</div>;
}

Get Wallet Balance

import { useBalance } from "@permi/react";

function WalletBalance() {
  const { data: balance, isLoading } = useBalance();

  if (isLoading) return <div>Loading...</div>;

  return (
    <div>
      Balance: {balance?.formatted} {balance?.symbol}
    </div>
  );
}

Get Viem Account

The useAccount hook returns a viem compatible account that can be used with viem clients:

import { useAccount } from "@permi/react";
import { createWalletClient, http } from "viem";
import { mainnet } from "viem/chains";

function SendTransaction() {
  const { data: account, isLoading } = useAccount();

  const sendTransaction = async () => {
    if (!account) return;

    const walletClient = createWalletClient({
      account,
      chain: mainnet,
      transport: http(),
    });

    const hash = await walletClient.sendTransaction({
      to: "0x...",
      value: BigInt(1000000000000000000), // 1 ETH
    });
  };

  if (isLoading) return <div>Loading...</div>;

  return (
    <button onClick={sendTransaction} disabled={!account}>
      Send Transaction
    </button>
  );
}

API Reference

Components

PermiProvider

Provider component that must wrap your application.

Props:

  • baseUrl: string - Permi API base URL
  • clientId: string - Your OAuth2 client ID
  • redirectUri: string - OAuth2 redirect URI
  • children: ReactNode - Your application components

Hooks

useAuth()

Authentication hook for login/logout functionality.

Returns:

  • isAuthenticated: boolean - Whether user is authenticated
  • isLoading: boolean - Whether authentication is loading
  • user: User | undefined - Current user info
  • login: () => void - Function to initiate login
  • logout: () => void - Function to logout
  • getAccessToken: () => string - Function to get current access token

useAddress(queryOptions?)

Hook to get the wallet address.

Returns: React Query result with wallet address as Address

useBalance(queryOptions?)

Hook to get the wallet balance.

Returns: React Query result with balance data

useAccount()

Hook to get a viem-compatible account object.

Returns:

  • data: Account | undefined - Viem account object
  • isLoading: boolean - Loading state

usePermiContext()

Access the Permi context directly.

Returns:

  • baseUrl: string - API base URL
  • getAccessToken: () => string - Function to get access token

Advanced Usage

Custom Query Options

All query hooks accept TanStack Query options:

const { data: address } = useAddress({
  refetchInterval: 5000, // Refetch every 5 seconds
  staleTime: 10000, // Consider data stale after 10 seconds
});

Error Handling

const { data, error, isError } = useBalance();

if (isError) {
  console.error("Failed to fetch balance:", error);
}

License

MIT