# Clerk bridge

> Use Glyph’s guards, useAuth() and screens with Clerk: the bridge mirrors Clerk’s session into Glyph.

Status: beta. Category: Auth.

```ts
import { ClerkAuthBridge } from '@glyphui/auth/clerk'
```

Exports: `ClerkAuthBridge`, `createClerkBridge`.

## Notes

- Glyph’s forms handle email and password, sign-up email codes, authenticator codes and reset codes through Clerk.
- OAuth redirects through Clerk: render Clerk’s <AuthenticateWithRedirectCallback /> at oauthCallbackUrl (default /sso-callback).
- Passkeys, enterprise SSO and bot protection need Clerk’s own components; use them alongside Glyph’s guards.
- Roles come from publicMetadata.roles plus the active organization role; permissions from publicMetadata.permissions.
- Clerk refreshes tokens and syncs tabs itself, so the bridge turns those Glyph timers off.
- auth.fetch sends Clerk’s session token as a bearer token.

## ClerkAuthBridge props

| Prop | Type | Default | Description |
|---|---|---|---|
| `afterOAuthUrl` | `string` |  | Where to land after OAuth completes. Default `/`. |
| `idleTimeout` | `number` |  | Sign the user out after this long without activity (ms). Off by default. |
| `idleWarning` | `number` |  | How long before the idle sign-out to warn (ms). Default 60 seconds. |
| `mapUser` | `((user: ClerkUserLike) => DefaultUser)` |  | Turns a Clerk user into your app's user type. |
| `oauthCallbackUrl` | `string` |  | Where Clerk returns after OAuth. Render Clerk's `<AuthenticateWithRedirectCallback />` there. |
| `oauthProviders` | `OAuthProvider[]` |  | Social buttons to offer. Default Google and GitHub. |
| `onSignOut` | `((reason: SignOutReason) => void)` |  | Called after any sign-out, with why it happened. |
| `refreshInterval` | `number \| false` |  | Re-check the session this often while the tab is open. Default 5 minutes; `false` to disable. |
| `refreshOnFocus` | `boolean` |  | Re-check the session when the tab regains focus. Default true. |
| `syncTabs` | `string \| boolean` |  | Keep tabs in sync: signing in or out in one tab updates the others. Pass a string to name the channel (useful when two apps share an origin). Default true. |

Live page: https://glyphui.xyz/components/auth-clerk
