Skip to main content
User management functions handle authentication, user creation, and profile retrieval in Film Fanatic.

store

Creates a new user or updates an existing user’s profile information. This mutation is typically called after authentication to store or update user details.
email
string
User’s email address
name
string
User’s display name
image
string
URL to the user’s profile image
userId
Id<'users'>
The ID of the created or updated user record
import { api } from "@/convex/_generated/api";
import { useMutation } from "convex/react";

const storeUser = useMutation(api.users.store);

// Store user after authentication
await storeUser({
  email: "[email protected]",
  name: "John Doe",
  image: "https://example.com/avatar.jpg"
});

Behavior

  • Requires authentication via ctx.auth.getUserIdentity()
  • If user exists (matched by tokenIdentifier), updates their profile
  • If user doesn’t exist, creates a new user record
  • Returns the user’s database ID in both cases

getStatus

Retrieves the current authenticated user’s profile information.
user
object | null
The user object if authenticated, or null if not authenticated
_id
Id<'users'>
User’s database ID
tokenIdentifier
string
Authentication token identifier
email
string
User’s email address
name
string
User’s display name
image
string
URL to user’s profile image
import { api } from "@/convex/_generated/api";
import { useQuery } from "convex/react";

const user = useQuery(api.users.getStatus);

if (user) {
  console.log(`Logged in as ${user.name}`);
} else {
  console.log("Not authenticated");
}

Behavior

  • Returns null if user is not authenticated
  • Returns the full user object if authenticated
  • Uses authentication context to find the user by tokenIdentifier

Build docs developers (and LLMs) love