Files
superlist/apps/web/src/lib/auth-client.ts
Jose Selesan 7ed4d27844 feat(auth): add passkey sign-in and management
Sign in with Face ID, Touch ID, Windows Hello or a security key, keeping
email + password as the primary method.

- API: BetterAuth passkey plugin deriving rpID/origin from WEB_APP_URL
  (the browser origin), with residentKey "required" because sign-in is
  username-less. New Passkey model mapped to the passkeys table.
- Web: conditional UI in the email field plus an explicit "Entrar con
  passkey" button; cancelled ceremonies are ignored.
- Settings: create, rename and delete passkeys with TanStack Query.
- Pin @better-auth/passkey to 1.7.7: its peers lock better-call, so
  newer versions break the API.
2026-10-29 11:37:38 -03:00

16 lines
634 B
TypeScript

import { passkeyClient } from '@better-auth/passkey/client'
import { emailOTPClient } from 'better-auth/client/plugins'
import { createAuthClient } from 'better-auth/react'
/**
* BetterAuth browser client. `baseURL` defaults to the page origin (the API is
* proxied under `/api` in dev and production) and can be overridden with
* `VITE_API_URL`. BetterAuth appends `/api/auth` itself.
*/
export const authClient = createAuthClient({
baseURL: import.meta.env.VITE_API_URL || window.location.origin,
plugins: [emailOTPClient(), passkeyClient()],
})
export const { signIn, signUp, signOut, useSession, emailOtp } = authClient