Lumen & Gesso / website · lumengesso.com / app / lib / auth-client.ts
| 1 | 'use client'; |
| 2 | |
| 3 | import { createAuthClient } from 'better-auth/client'; |
| 4 | import { passkeyClient } from '@better-auth/passkey/client'; |
| 5 | |
| 6 | export const authClient = createAuthClient({ basePath: '/api/auth', plugins: [passkeyClient()] }); |
| 7 | |
| 8 | /** New here: create an account with only a passkey, then sign in with it. */ |
| 9 | export async function createPasskeyAccount(): Promise<string | null> { |
| 10 | const made = await authClient.passkey.addPasskey({ name: 'Lumen & Gesso' }); |
| 11 | if (made?.error) return 'The passkey wasn’t saved. Try again.'; |
| 12 | const signed = await authClient.signIn.passkey(); |
| 13 | return signed?.error ? 'Your passkey is saved. Tap Sign in with passkey to continue.' : null; |
| 14 | } |