Clerk bridge

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

Status: beta. Category: Auth.

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

PropTypeDefaultDescription
afterOAuthUrlstringWhere to land after OAuth completes. Default /.
idleTimeoutnumberSign the user out after this long without activity (ms). Off by default.
idleWarningnumberHow 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.
oauthCallbackUrlstringWhere Clerk returns after OAuth. Render Clerk's <AuthenticateWithRedirectCallback /> there.
oauthProvidersOAuthProvider[]Social buttons to offer. Default Google and GitHub.
onSignOut((reason: SignOutReason) => void)Called after any sign-out, with why it happened.
refreshIntervalnumber | falseRe-check the session this often while the tab is open. Default 5 minutes; false to disable.
refreshOnFocusbooleanRe-check the session when the tab regains focus. Default true.
syncTabsstring | booleanKeep 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