Clerk-style React auth for Next.js
keycloak-react
React components for Keycloak with SSR support — built on Auth.js so tokens stay server-side and never reach the browser.
View on GitHub
npm install keycloak-react next-auth
Tokens stay server-side
Access and refresh tokens live in HTTP-only cookies and the JWT — the client only sees session info, never raw tokens.
Clerk-inspired DX
Drop-in React components for sign-in flows, user menus, and role-gated content in Next.js App Router apps.
Auth.js under the hood
Built on NextAuth v5 with a Keycloak provider — familiar patterns with enterprise-grade identity behind them.
Features
- SSR-first authentication using Auth.js with Keycloak provider
- Pre-built UI components — user avatar, sign-in/out buttons, user menu
- SignedIn, SignedOut, and Protect conditional rendering components
- Server-side session and token management with automatic refresh
- Role-based access control via useHasRole and Protect