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

# Bijection & Clerk

Configure the Bijection deployment to verify tokens from Clerk. Set the
issuer and audience for the application token in
[`bijection/sign-in.ts`](https://docs.bijection.com/reference/configuration/auth-config).
[OIDC providers](https://docs.bijection.com/access/authentication/custom-oidc.md) describes the
configuration fields.

Use Clerk's React library to sign in, and the `clerk()` adapter from
`@bijectionhq/bijection/client` to give the client its token:

```tsx theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { useAuth } from "@clerk/clerk-react";
import { clerk, connect } from "@bijectionhq/bijection/client";
import { Bijection, useClientAuth } from "@bijectionhq/bijection/react";
import type { ReactNode } from "react";
import type App from "../bijection/app";

export const auth = clerk({ template: "bijection" });
export const client = connect(import.meta.env.VITE_BIJECTION_URL, { contract: "discover", token: auth });

// Render inside <ClerkProvider>.
function SignedInView({ children }: { children: ReactNode }) {
  const ready = useClientAuth(auth, useAuth());
  return ready ? <Bijection client={client}>{children}</Bijection> : null;
}
```

`template` names the Clerk JWT template whose token the deployment verifies.
Omit it to use Clerk's session token. The adapter withdraws watch answers when
Clerk starts loading again or changes the session, active organization, or
reported session-token audience. It supplies no authenticated credential if
the signed-in state lacks a session ID or the active organization is unknown.
Use a fixed audience for a custom template. Clerk's `useAuth()` exposes
session-token claims, so use a custom `ClientAuth` if your template's audience
can change independently of the session or organization. In a server request,
create a client with that user's token using `connect(url, { contract: "discover", token })`.

For access to protected application data, give the verified subject the
[roles your app requires](https://docs.bijection.com/access/grants.md). Use the
[verified principal](https://docs.bijection.com/access/authentication/functions.md), `ctx.frame.as`, for attribution.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.