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

@fast-auth-near/react-sdk

v1.0.0

Published

React SDK for FastAuth - A provider-agnostic authentication solution for NEAR Protocol.

Readme

@fast-auth/react

React SDK for FastAuth - A provider-agnostic authentication solution for NEAR Protocol.

Features

  • 🔐 Provider-agnostic: Works with any auth provider implementing the IFastAuthProvider interface
  • ⚛️ React-first: Built with React best practices (hooks, context, memoization)
  • 🎯 Type-safe: Full TypeScript support with comprehensive type definitions
  • 🪝 Multiple hooks: Convenient hooks for common operations
  • 📦 Zero-config: Sensible defaults with full customization options
  • 🔄 State management: Built-in loading, error, and authentication state management

Installation

npm install @fast-auth/react near-api-js
# or
pnpm add @fast-auth/react near-api-js
# or
yarn add @fast-auth/react near-api-js

Usage

Basic Setup

import { FastAuthProvider } from '@fast-auth/react';
import { Connection } from 'near-api-js';
import { YourAuthProvider } from '@your-auth/provider';

const connection = new Connection({
  networkId: 'testnet',
  provider: { type: 'JsonRpcProvider', args: { url: 'https://rpc.testnet.near.org' } },
});

const clientOptions = {
  mpcContractId: 'v1.signer-prod.testnet',
  fastAuthContractId: 'fastauth.testnet',
};

function App() {
  const providerConfig = {
    provider: new YourAuthProvider({
      // Your provider configuration
    }),
  };

  return (
    <FastAuthProvider
      providerConfig={providerConfig}
      connection={connection}
      clientOptions={clientOptions}
    >
      <YourApp />
    </FastAuthProvider>
  );
}

With React Provider Wrapper

If your auth provider has its own React provider (like react-native-auth0), you can wrap it:

import { Auth0Provider } from 'react-native-auth0';

const providerConfig = {
  provider: new YourAuthProvider({
    // Your provider configuration
  }),
  reactProvider: (children) => (
    <Auth0Provider domain="your-domain.auth0.com" clientId="your-client-id">
      {children}
    </Auth0Provider>
  ),
};

function App() {
  return (
    <FastAuthProvider
      providerConfig={providerConfig}
      connection={connection}
      clientOptions={clientOptions}
    >
      <YourApp />
    </FastAuthProvider>
  );
}

Hooks

useFastAuth

Main hook to access the FastAuth client and ready state.

import { useFastAuth } from '@fast-auth/react';

function MyComponent() {
  const { client, isReady } = useFastAuth();

  if (!isReady || !client) {
    return <div>Initializing...</div>;
  }

  // Use client directly for all operations
  const handleLogin = async () => {
    await client.login();
  };

  const handleLogout = async () => {
    await client.logout();
  };

  return (
    <div>
      <button onClick={handleLogin}>Login</button>
      <button onClick={handleLogout}>Logout</button>
    </div>
  );
}

useIsLoggedIn

Convenient hook to check login status with loading and error states.

import { useIsLoggedIn } from '@fast-auth/react';

function LoginButton() {
  const { isLoggedIn, isLoading, error } = useIsLoggedIn();

  if (isLoading) {
    return <div>Checking status...</div>;
  }

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

  return <div>{isLoggedIn ? 'Logged in' : 'Not logged in'}</div>;
}

useSigner

Hook to get the FastAuth signer with automatic state management.

import { useSigner } from '@fast-auth/react';

function SignerComponent() {
  const { signer, isLoading, error, refetch } = useSigner();

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

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

  if (!signer) {
    return <div>Please log in</div>;
  }

  return <div>Signer ready!</div>;
}

usePublicKey

Hook to get the user's public key.

import { usePublicKey } from '@fast-auth/react';

function PublicKeyDisplay() {
  const { publicKey, isLoading, error } = usePublicKey('ed25519');

  if (isLoading) {
    return <div>Loading public key...</div>;
  }

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

  if (!publicKey) {
    return <div>Please log in</div>;
  }

  return <div>Public Key: {publicKey.toString()}</div>;
}

Creating a Custom Provider

To create a custom auth provider, implement the IFastAuthProvider interface:

import { IFastAuthProvider } from '@fast-auth/react';

export class MyCustomProvider implements IFastAuthProvider {
  async isLoggedIn(): Promise<boolean> {
    // Check if user is logged in
  }

  async login(...args: any[]): Promise<void> {
    // Implement login logic
  }

  async logout(): Promise<void> {
    // Implement logout logic
  }

  async getPath(): Promise<string> {
    // Return the user's path
  }

  async requestTransactionSignature(...args: any[]): Promise<void> {
    // Request transaction signature
  }

  async requestDelegateActionSignature(...args: any[]): Promise<void> {
    // Request delegate action signature
  }

  async getSignatureRequest(): Promise<SignatureRequest> {
    // Get signature request
  }
}

TypeScript

The SDK is fully typed. You can use generic types for better type inference:

import { useFastAuth } from '@fast-auth/react';
import { MyCustomProvider } from './my-provider';

function MyComponent() {
  const { login } = useFastAuth<MyCustomProvider>();

  // TypeScript will infer the correct parameter types for login
  const handleLogin = () => {
    login(/* correctly typed parameters */);
  };
}

API Reference

FastAuthProvider Props

| Prop | Type | Required | Description | |-------------------|-----------------------------------|----------|--------------------------------------------------| | providerConfig | FastAuthProviderConfig | Yes | Provider configuration | | connection | Connection | Yes | NEAR connection instance | | clientOptions | FastAuthClientOptions | Yes | FastAuth client options |

FastAuthProviderConfig

| Property | Type | Required | Description | |------------------|-----------------------------------|----------|--------------------------------------| | provider | IFastAuthProvider | Yes | Auth provider implementation | | reactProvider | (children: ReactNode) => ReactNode | No | Optional React provider wrapper |

IFastAuthContext

See the type definitions in the source code for a complete list of available methods and properties.

Examples

See the examples/ directory for complete examples using different providers.

License

MIT