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

@sooapps/sooauth-react

v0.1.5

Published

React SDK for SooAuth hosted authentication.

Readme

@sooapps/sooauth-react

React SDK for SooAuth hosted authentication.

Use this package when your React app should send users to SooAuth hosted sign-in/sign-up pages, receive the callback code, exchange it for tokens, and expose the signed-in user through React hooks/components.

Links

  • Console: https://sooauth.com/dashboard
  • Hosted auth: https://sooauth.com/sign-in
  • API issuer: https://api.sooauth.com
  • Docs: https://sooauth.com/docs
  • GitHub: https://github.com/sooapps/sooauth-react

Install

npm install @sooapps/sooauth-react
pnpm add @sooapps/sooauth-react

Example App

This repository includes a public Vite example:

cd examples/vite
npm install
cp .env.example .env
npm run dev

Before running it, create a SooAuth application and set:

Redirect URL: http://localhost:5173/auth/callback
Allowed origin: http://localhost:5173

Then put your application client ID in .env:

VITE_SOOAUTH_CLIENT_ID=app_xxx

Configure Your SooAuth Application

Open the SooAuth console:

https://sooauth.com/dashboard

Create or open an application, then set these values:

Applications -> Manage -> Settings
Redirect URL: https://yourapp.com/auth/callback
Allowed origin: https://yourapp.com

Redirect URL is your frontend callback route. It is not your backend API URL.

Wrap Your React App

import { SooAuthProvider } from "@sooapps/sooauth-react";

export function Root() {
  return (
    <SooAuthProvider
      clientId="app_xxx"
      redirectUri="https://yourapp.com/auth/callback"
      apiUrl="https://api.sooauth.com"
      hostedUrl="https://sooauth.com"
    >
      <App />
    </SooAuthProvider>
  );
}

Add Sign In And Sign Up Buttons

import { SignedIn, SignedOut, UserButton, useAuth } from "@sooapps/sooauth-react";

export function AuthButtons() {
  const { signIn, signUp } = useAuth();

  return (
    <>
      <SignedOut>
        <button onClick={() => signIn.redirect()}>Sign in</button>
        <button onClick={() => signUp.redirect()}>Sign up</button>
      </SignedOut>

      <SignedIn>
        <UserButton />
      </SignedIn>
    </>
  );
}

Add The Hosted Callback Route

Create a frontend route at the same URL you configured as the Redirect URL.

For example:

https://yourapp.com/auth/callback

Then call handleRedirectCallback().

import { useEffect } from "react";
import { useAuth } from "@sooapps/sooauth-react";

export function AuthCallback() {
  const { handleRedirectCallback } = useAuth();

  useEffect(() => {
    handleRedirectCallback().then(() => {
      window.location.assign("/");
    });
  }, [handleRedirectCallback]);

  return <main>Completing sign in...</main>;
}

Call Your Backend With The Access Token

import { useAuth } from "@sooapps/sooauth-react";

export function LoadPrivateDataButton() {
  const { getAccessToken } = useAuth();

  async function loadPrivateData() {
    const token = getAccessToken();

    const res = await fetch("https://api.yourapp.com/private", {
      headers: {
        Authorization: `Bearer ${token}`,
      },
    });

    return res.json();
  }

  return <button onClick={loadPrivateData}>Load private data</button>;
}

Your backend should verify the JWT audience against the SooAuth application client ID.

Email And Password

Hosted sign-in is the recommended flow.

If you want embedded email/password forms:

import { useAuth } from "@sooapps/sooauth-react";

export function LoginForm() {
  const { signIn, signUp } = useAuth();

  async function login(email: string, password: string) {
    await signIn.email(email, password);
  }

  async function register(email: string, password: string, name?: string) {
    await signUp.email(email, password, name);
  }
}

Forgot And Reset Password

import { useAuth } from "@sooapps/sooauth-react";

export function PasswordResetForm() {
  const { forgotPassword, resetPassword } = useAuth();

  async function requestReset(email: string) {
    await forgotPassword(email, "https://yourapp.com/reset-password");
  }

  async function completeReset(token: string, newPassword: string) {
    await resetPassword(token, newPassword);
  }
}

Google OAuth

Enable Google OAuth in the SooAuth console:

Applications -> Manage -> Auth methods

Then use the normal hosted redirect:

import { useAuth } from "@sooapps/sooauth-react";

export function GoogleButton() {
  const { signIn } = useAuth();
  return <button onClick={() => signIn.redirect()}>Continue with Google</button>;
}

The hosted sign-in page shows Google automatically when it is enabled for the application.

AI Agent Prompt

Paste this into an AI coding agent inside the app you want to connect:

Integrate SooAuth into this React project.

Use these values:
- Client ID: app_xxx
- API URL: https://api.sooauth.com
- Hosted auth URL: https://sooauth.com
- Redirect URI: https://yourapp.com/auth/callback

Tasks:
1. Install @sooapps/sooauth-react.
2. Wrap the React app with SooAuthProvider.
3. Add an /auth/callback route that calls handleRedirectCallback().
4. Replace local sign-in/sign-up buttons with signIn.redirect() and signUp.redirect().
5. Use getAccessToken() for protected backend requests.
6. Show SignedIn and SignedOut UI states.
7. Do not replace existing business logic; only gate protected UI/actions behind SooAuth.
8. Validate by signing in, calling a protected endpoint, signing out, and refreshing the page.

Public API

const {
  user,
  isLoaded,
  isSignedIn,
  signIn,
  signUp,
  signOut,
  refresh,
  forgotPassword,
  resetPassword,
  handleRedirectCallback,
  getAccessToken,
} = useAuth();

Components:

<SignedIn />
<SignedOut />
<UserButton />