// the find
authts/react-oidc-context
Lightweight auth library based on oidc-client-ts for React single page applications (SPA). Support for hooks and higher-order components (HOC).
A thin React wrapper around oidc-client-ts that gives you a context provider, a useAuth hook, and HOCs for class components and protected routes. It's for teams already comfortable with raw OIDC/UserManager concepts who want React bindings without a heavier auth SDK.
Stays genuinely lightweight by delegating all the actual OIDC protocol work to oidc-client-ts instead of reimplementing it, so the library's own surface area is small and easy to audit. Test coverage is taken seriously — Jest, Codecov, and per-hook/per-HOC test files including an SSR test, not just a token integration test. Covers the real range of usage patterns people hit in practice: hooks, class-component HOC, route protection, manual event listener wiring, and auto sign-in, rather than just the happy-path hook. Uses api-extractor to track the public API surface, which means breaking changes are less likely to slip in unnoticed.
Configuration is tightly coupled to oidc-client-ts's UserManagerSettings, so you're effectively learning two libraries' docs to configure one of them. The onSigninCallback requirement is a real footgun: the README states you must implement it to strip auth params from the URL or silent renew silently breaks, and that's the kind of thing that surfaces as a confusing bug days later, not at setup time. Route protection is a single withAuthenticationRequired HOC with no story for role-based or nested guards — anything beyond 'logged in or not' is on you. There's no built-in pattern for multiple OIDC providers or multi-tenant auth in one app; you'd be nesting or rolling your own context to get that.