Auth SDK for React with JWT, Mantine UI components, and full authentication flows
npm install @riligar/auth-reactAuth SDK for React with JWT and JWKS.
``bash`
bun add @riligar/auth-react
`jsx
import { AuthProvider, useAuth, useSignIn, Protect, SignedIn, SignedOut, SignIn } from '@riligar/auth-react'
// 1. Wrap your app with AuthProvider
function App() {
return (
element={
/>
element={
/>
)
}
// 2. Use control components for conditional rendering
function Header() {
return (
)
}
`
| Component | Description |
| ----------------------- | -------------------------------------------- |
| | Sign in form with email/password, magic link |
| | Registration form |
| | Magic link request form |
| | Magic link verification |
| | Password reset request |
| | Password reset form |
| | Email verification |
| | User profile management modal |
| Component | Description |
| --------------- | -------------------------------------------- |
| | Renders children only when authenticated |
| | Renders children only when NOT authenticated |
| | Renders children while auth is loading |
| | Renders children when auth has loaded |
| | Protected route wrapper |
| Component | Description |
| ------------------- | ------------------------- |
| | Navigates to sign-in page |
| | Navigates to sign-up page |
| | Signs out the user |
`jsx`
const { user, loading, error, isAuthenticated } = useAuth()
const { user, updateProfile, changePassword, changeEmail } = useUser()
const signIn = useSignIn()
const signUp = useSignUp()
const signOut = useSignOut()
- ✅ JWT Tokens - Secure token-based authentication
- ✅ JWKS - Signature verification with /.well-known/jwks.json
- ✅ Auto refresh - Tokens renewed automatically
- ✅ Social login - OAuth provider support
- ✅ Cross-tab sync - Synchronized state across tabs
- ✅ Route protection - Protected routes automatically
- ✅ Control components - Clerk-style conditional rendering
- ✅ SSR friendly - Server-side rendering compatible
The following deprecated aliases are still available:
| Deprecated | Use Instead |
| -------------------- | ------------------- |
| SignInForm | SignIn |SignUpForm
| | SignUp |MagicLinkForm
| | MagicLink |MagicLinkVerify
| | MagicLinkCallback |ForgotPasswordForm
| | ForgotPassword |ResetPasswordForm
| | ResetPassword |VerifyEmailCard
| | VerifyEmail |AccountModal
| | UserProfile |ProtectedRoute
| | Protect |useProfile
| | useUser |
The SDK expects your backend to expose:
- /.well-known/jwks.json - Public keys for JWT verification/auth/sign-in
- - Login (returns { token, user })/auth/sign-up
- - Registration (returns { token, user })/auth/sign-out
- - Logout/auth/refresh
- - Token renewal/auth/sign-in/:provider
- - Social login
`bash``
bun run build