> ## Documentation Index
> Fetch the complete documentation index at: https://confect.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication

> Access the current user's identity in your Confect functions.

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

```ts theme={null}
import * as Effect from "effect/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`](https://docs.convex.dev/api/interfaces/server.UserIdentity) or fails with `NoUserIdentityFoundError`.

## Handling unauthenticated requests

Use `Effect.catchTag` to handle the case where no user is logged in.

```ts theme={null}
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](https://docs.convex.dev/auth) for setup details.
