import { useAuth } from '@kerne/react';
function Profile() {
const { user, isAuthenticated, isLoading, logout, updateProfile } = useAuth();
if (isLoading) return <Spinner />;
if (!isAuthenticated) return <p>Not logged in</p>;
return (
<div>
<p>{user?.first_name ?? user?.email}</p>
<button onClick={() => updateProfile({ first_name: 'New name' })}>Rename</button>
<button onClick={logout}>Log out</button>
</div>
);
}
useAuth() reference
| Property | Type | Notes |
|---|---|---|
user | User | null | Full profile - id, email, email_verified, first_name, last_name, avatar, … |
isAuthenticated | boolean | |
isLoading | boolean | true while the stored session is still being read on mount. |
logout | () => void | Clears the session locally - no server round-trip. |
refreshUser | () => Promise<User | null> | Re-fetches user from the server. |
updateProfile | (params: { first_name?, last_name? }) => Promise<User> | No avatar here - the API doesn’t accept it on this route. |
updatePassword | (params: { currentPassword, newPassword }) => Promise<void> |
autoRefresh/refreshBuffer on KerneProvider.
Errors
| Code | Meaning |
|---|---|
K1006 | Token expired. |
K1007 | No token provided. |

