@shoojs/react
v0.2.2
Published
React hooks wrapper for `@shoojs/auth`.
Downloads
662
Readme
@shoojs/react
React hooks wrapper for @shoojs/auth.
Install
npm install @shoojs/react @shoojs/authUsage
import { useShooAuth } from "@shoojs/react";
export function App() {
const auth = useShooAuth({
shooBaseUrl: "https://shoo.dev",
callbackPath: "/auth/callback",
autoSessionMonitor: true,
sessionMonitorIntervalMs: 60_000
});
return (
<div>
<button onClick={() => void auth.signIn()}>Sign In</button>
<button onClick={() => void auth.checkSession()}>Check Session</button>
<p>{auth.identity.userId ?? "Signed out"}</p>
<p>Session state: {auth.sessionState}</p>
</div>
);
}Session checks
useShooAuthexposescheckSession()for explicit revocation/session validation.- When
autoSessionMonitoris enabled (default), the hook runs periodic background checks and clears local identity onlogin_required.
