Skip to content

useUser hook

The useUser hook is a custom React hook that returns the current authenticated user.

Example usage:

app/pages/example/index.jsx
jsx
import { Page, useUser } from '@kottster/react';

export default () => {
  const { user } = useUser();

  return (
    <Page>
      Current User Email: {user.email}
    </Page>
  );
};

Returned values

  • user: object - The current user object, which includes all public properties of the user.
  • permissions: string[] - An array of permissions associated with the current user.
  • hasRole: (role: string) => boolean - A function that checks if the current user has a specific role.