@aegistry/react
v0.1.1
Published
React bindings for the aegistry auth client
Downloads
282
Readme
@aegistry/react
React bindings for @aegistry/client, the TypeScript client for aegistry — the FastAPI authentication library.
npm install @aegistry/reactUsage
// lib/auth.ts
import { createAuthClient } from "@aegistry/react";
export const auth = createAuthClient();
export const { useSession } = auth;"use client";
import { auth, useSession } from "../lib/auth";
export function UserMenu() {
const { data: session, isPending } = useSession();
if (isPending) return <span>…</span>;
if (!session) return <a href="/login">Sign in</a>;
return <button onClick={() => auth.signOut()}>Sign out</button>;
}createAuthClient re-exports everything from @aegistry/client (password, email OTP, and OAuth sign-in; changePassword; signOut) and adds the useSession() hook, which subscribes to the shared session store and re-renders on auth changes.
See the aegistry repository for the FastAPI side and a full Next.js example.
