Entity Auth

Convex React Adapter (@entityauth/react-convex)

Live user profile hook for Convex apps integrated with Entity Auth

Install

pnpm add @entityauth/react-convex @entityauth/react

Peer deps:

  • react >= 18
  • convex >= 1
  • @entityauth/react >= 0.0.1

Usage

Create a typed hook bound to your Convex API.

// hooks/useUserProfile.ts
import { api } from '@/convex/_generated/api';
import { createUseUserProfile } from '@entityauth/react-convex';

export const useUserProfile = createUseUserProfile(api);

Use it in your components. Make sure your app is wrapped with EntityAuthProvider from @entityauth/react.

import { useUserProfile } from '@/hooks/useUserProfile';

export function ProfilePanel() {
  const { me, user, oauthCredentials, hasPasswordCredential, isLoading } = useUserProfile();
  if (isLoading) return <div>Loading…</div>;
  return (
    <pre>
      {JSON.stringify({ me, user, oauthCredentials, hasPasswordCredential }, null, 2)}
    </pre>
  );
}

What it returns

  • me: The Entity Auth me payload (id, email, username, workspaceTenantId).
  • user: The Convex auth.users.getById result for the current user id (or undefined while loading).
  • oauthCredentials: List of linked OAuth credentials for the current user (if any).
  • hasPasswordCredential: true if a password credential exists, false if not, null if unknown.
  • isLoading: true while queries are pending with a valid user id.

How it works

Internally, the adapter reads auth state from @entityauth/react, then issues Convex useQuery calls:

  • api.auth.users.getById({ id })
  • api.entities.list({ workspaceTenantId, kind: 'credential', limit: 250 })

It derives the credential summary for convenient UI rendering.

See also