Skip to main content
The Auth service provides access to the current user’s identity. Unlike vanilla Convex (which returns UserIdentity | null), the Confect Auth service returns an Effect that fails with a typed error when no user is authenticated.

Getting the user identity

import { Effect } from "effect";
import { Auth } from "./confect/_generated/services";

Effect.gen(function* () {
  const auth = yield* Auth;

  const identity = yield* auth.getUserIdentity;
});
getUserIdentity succeeds with the user’s UserIdentity or fails with NoUserIdentityFoundError.

Handling unauthenticated requests

Use Effect.catchTag to handle the case where no user is logged in.
Effect.gen(function* () {
  const auth = yield* Auth;

  const identity = yield* auth.getUserIdentity.pipe(
    Effect.catchTag("NoUserIdentityFoundError", () =>
      Effect.succeed(null),
    ),
  );
});

Configuration

Auth provider configuration goes in confect/auth.ts, which is passed through to Convex as-is. See the Convex auth documentation for setup details.