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.
16 lines
634 B
TypeScript
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
|