This guide walks you through implementing complete authentication with login, registration, and session management.
Prerequisites
- A Kerne account with an app created
- Your
appId and secretKey from the Kerne dashboard
- A backend (Node.js, Next.js, etc.) and React frontend
1. Install the SDKs
Create a server-side Kerne client:
Never expose your secretKey on the client. It should only be used in server-side code.
3. Set up the React provider
Wrap your app with KerneProvider:
Use the useAuth hook:
6. Protect routes
The simplest way is the <Authenticated> guard - no redirect wiring needed just to hide a page:
It renders fallback for as long as there’s no confirmed session - that includes the moment the session is still loading, not only an actual logged-out visitor. If that brief flash matters for a given page, branch on isLoading yourself with useAuth() before deciding what to show.
If you specifically need a URL redirect (not just hiding content), do the same off isAuthenticated/isLoading from useAuth() with whatever router your framework provides.
Next steps