Skip to content

Add React hooks for the passkey provider - #463

Draft
Nicolapps wants to merge 1 commit into
nicolas/passkey-providerfrom
nicolas/passkey-react
Draft

Add React hooks for the passkey provider#463
Nicolapps wants to merge 1 commit into
nicolas/passkey-providerfrom
nicolas/passkey-react

Conversation

@Nicolapps

@Nicolapps Nicolapps commented Aug 13, 2026

Copy link
Copy Markdown
Member

Adds the React client for the passkey provider, exported at @convex-dev/auth/providers/passkey/react. This is the first browser-side WebAuthn code in the repo.

  • useSignInWithPasskey({ startSignIn, finishSignIn, finishSignUp }){ signIn({ username }), pending }: orchestrates start → credentials.create()/get() → finish → setSession.
  • usePasskeyAutofill({ startAutofillSignIn, finishSignIn }){ available, status, lastError, cancel }: keeps a conditional-mediation request pending and refreshes the challenge every ~8 minutes (server TTL is 10). One async loop per effect run, StrictMode-safe by construction; abort reasons (STOP/REFRESH/PAUSE) drive the state machine.
  • A module-scoped coordinator lets the modal flow pause the pending autofill request and resume it afterwards — browsers reject a modal ceremony while a conditional request is pending on the same page. The residual double-setSession race is harmless and commented.
  • Client-side failures fold into the result union (CEREMONY_ABORTED, WEBAUTHN_UNSUPPORTED, OTHER_ERROR with cause), extending the password provider's OTHER_ERROR pattern, so callers handle every failure through one userError switch.
  • WebAuthn details: raw bytes end to end (no base64), rawId as the credential id, pubKeyCredParams exactly ES256/RS256, discoverable credentials + user verification required.

Part 4/5 of the username+passkey provider stack.

Test plan

  • pnpm typecheck / pnpm lint green.
  • Exercised in the react-passkey example (PR 5/5), including the modal-while-autofill interleaving.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Aug 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
auth-v2 Ready Ready Preview Aug 14, 2026 11:15pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
convex-auth-docs Ignored Ignored Aug 14, 2026 11:15pm

Request Review

Nicolapps commented Aug 13, 2026

Copy link
Copy Markdown
Member Author

@pkg-pr-new

pkg-pr-new Bot commented Aug 13, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@convex-dev/auth@463

commit: 486c809

@Nicolapps
Nicolapps force-pushed the nicolas/passkey-react branch from 427c004 to eebef3c Compare August 13, 2026 23:57
@Nicolapps
Nicolapps force-pushed the nicolas/passkey-provider branch from 93db3ba to 0380fbd Compare August 13, 2026 23:57
@Nicolapps
Nicolapps force-pushed the nicolas/passkey-provider branch from 0380fbd to cee48ec Compare August 14, 2026 15:29
@Nicolapps
Nicolapps force-pushed the nicolas/passkey-react branch from eebef3c to ae06652 Compare August 14, 2026 15:29
@Nicolapps
Nicolapps force-pushed the nicolas/passkey-react branch from ae06652 to a60f8ab Compare August 14, 2026 16:35
@Nicolapps
Nicolapps force-pushed the nicolas/passkey-provider branch from cee48ec to c129405 Compare August 14, 2026 16:35
@Nicolapps
Nicolapps force-pushed the nicolas/passkey-provider branch from c129405 to fd20927 Compare August 14, 2026 16:50
@Nicolapps
Nicolapps force-pushed the nicolas/passkey-react branch from a60f8ab to aa1b403 Compare August 14, 2026 16:50
@Nicolapps
Nicolapps force-pushed the nicolas/passkey-react branch from aa1b403 to 3d119b7 Compare August 14, 2026 17:59
@Nicolapps
Nicolapps force-pushed the nicolas/passkey-provider branch from fd20927 to 0ab1995 Compare August 14, 2026 17:59
@Nicolapps
Nicolapps force-pushed the nicolas/passkey-provider branch from 0ab1995 to b1422e0 Compare August 14, 2026 21:18
- `useSignInWithPasskey`: the identifier-first flow. It asks the
  backend which ceremony applies, runs the WebAuthn dialog, finishes
  the ceremony, and adopts the session.
- `usePasskeyAutofill`: conditional mediation (passkey autofill).
  One pending browser request at a time, with an automatic challenge
  refresh before the 10-minute server TTL.

A module-scoped coordinator pauses the pending autofill request while
a modal ceremony runs: browsers reject a modal `create()`/`get()`
while a conditional request is pending on the same page.

Client-side failures fold into the result union as CEREMONY_ABORTED /
WEBAUTHN_UNSUPPORTED / OTHER_ERROR, so callers handle every failure
through one `userError` switch.

Exported at `@convex-dev/auth/providers/passkey/react`.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant