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 >= 18convex >= 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 Authmepayload (id, email, username, workspaceTenantId).user: The Convexauth.users.getByIdresult for the current user id (orundefinedwhile loading).oauthCredentials: List of linked OAuth credentials for the current user (if any).hasPasswordCredential:trueif a password credential exists,falseif not,nullif unknown.isLoading:truewhile 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
- React SDK: /docs/sdk-react
- Convex OIDC basics: /docs/integrations/convex