Plugin: Passkey - Signin callback doesn't exist #748

Closed
opened 2026-03-13 08:02:43 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @char-ptr on GitHub (Feb 27, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. setup better auth to use passkeys
  2. make signin page
  3. attempt to use passkeys to signin and add a callback url

Current vs. Expected behavior

current: authClient.signIn.passkey function does not have a param to accept callback url
expected: authClient.signIn.passkey function does has param to accept callback url

What version of Better Auth are you using?

1.1.21

Provide environment information

- OS: Windows 10
- Browser: Firefox

Which area(s) are affected? (Select all that apply)

Documentation, Client

Auth config (if applicable)

import { betterAuth } from "better-auth"
import { passkey } from "better-auth/plugins/passkey"

export const auth = betterAuth({
   plugins: [
    passkey(),
  ]
});
// client
import { createAuthClient } from "better-auth/react"
import { passkeyClient } from "better-auth/client/plugins"
const authClient = createAuthClient({
  baseURL: "https://localhost:3000",
  plugins: [
    passkeyClient()
  ]
})

Additional context

In documentation it specifies that there should be a callback field, yet there is no such field:
https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/plugins/passkey/client.ts#L27-L32
Image

Originally created by @char-ptr on GitHub (Feb 27, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. setup better auth to use passkeys 2. make signin page 3. attempt to use passkeys to signin and add a callback url ### Current vs. Expected behavior current: `authClient.signIn.passkey` function does not have a param to accept callback url expected: `authClient.signIn.passkey` function does has param to accept callback url ### What version of Better Auth are you using? 1.1.21 ### Provide environment information ```bash - OS: Windows 10 - Browser: Firefox ``` ### Which area(s) are affected? (Select all that apply) Documentation, Client ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" import { passkey } from "better-auth/plugins/passkey" export const auth = betterAuth({ plugins: [ passkey(), ] }); // client import { createAuthClient } from "better-auth/react" import { passkeyClient } from "better-auth/client/plugins" const authClient = createAuthClient({ baseURL: "https://localhost:3000", plugins: [ passkeyClient() ] }) ``` ### Additional context In documentation it specifies that there should be a callback field, yet there is no such field: https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/plugins/passkey/client.ts#L27-L32 ![Image](https://github.com/user-attachments/assets/73e54f97-ecfd-41e0-856f-76a85bb233ae) - https://better-auth.vercel.app/docs/plugins/passkey#signin-with-a-passkey
GiteaMirror added the bug label 2026-03-13 08:02:43 -05:00
Author
Owner

@codedusting commented on GitHub (Mar 3, 2025):

It also doesn't work without registration and registration gives "SESSION_IS_NOT_FRESH" error. I think this passkey feature is broken?

@codedusting commented on GitHub (Mar 3, 2025): It also doesn't work without registration and registration gives "SESSION_IS_NOT_FRESH" error. I think this passkey feature is broken?
Author
Owner

@codedusting commented on GitHub (Mar 22, 2025):

It also doesn't work without registration and registration gives "SESSION_IS_NOT_FRESH" error. I think this passkey feature is broken?

Is there any way around for the above?

@codedusting commented on GitHub (Mar 22, 2025): > It also doesn't work without registration and registration gives "SESSION_IS_NOT_FRESH" error. I think this passkey feature is broken? Is there any way around for the above?
Author
Owner

@DimitarY commented on GitHub (Mar 28, 2025):

It also doesn't work without registration and registration gives "SESSION_IS_NOT_FRESH" error. I think this passkey feature is broken?

Is there any way around for the above?

You need to disable the freshAge on the session or you need to refresh the current session

https://www.better-auth.com/docs/concepts/session-management#session-freshness

@DimitarY commented on GitHub (Mar 28, 2025): > > It also doesn't work without registration and registration gives "SESSION_IS_NOT_FRESH" error. I think this passkey feature is broken? > > Is there any way around for the above? You need to disable the freshAge on the session or you need to refresh the current session https://www.better-auth.com/docs/concepts/session-management#session-freshness
Author
Owner

@DimitarY commented on GitHub (Mar 28, 2025):

I tested the passkey on v1.2.5 and it is still missing the callbackURL as described in docs
https://www.better-auth.com/docs/plugins/passkey#signin-with-a-passkey

Also, I found that when user sign-in with passskey the current page is not updated and only when user manually refresh the page content is updated and user is signed in.

@DimitarY commented on GitHub (Mar 28, 2025): I tested the passkey on v1.2.5 and it is still missing the callbackURL as described in docs https://www.better-auth.com/docs/plugins/passkey#signin-with-a-passkey Also, I found that when user sign-in with passskey the current page is not updated and only when user manually refresh the page content is updated and user is signed in.
Author
Owner

@jim-y commented on GitHub (Mar 30, 2025):

For the time-being you can use the onSuccess callback and do a manual redirect/route as:

void authClient.signIn.passkey(
	{
		autoFill: true,
		email
	},
	{
		onSuccess: () => {
			if (this.redirectTo) {
				window.location.href = this.redirectTo;
			} else {
				void this.router.navigate(['/user/profile']);
			}
		}
	}
);
@jim-y commented on GitHub (Mar 30, 2025): For the time-being you can use the onSuccess callback and do a manual redirect/route as: ```ts void authClient.signIn.passkey( { autoFill: true, email }, { onSuccess: () => { if (this.redirectTo) { window.location.href = this.redirectTo; } else { void this.router.navigate(['/user/profile']); } } } ); ```
Author
Owner

@leavism commented on GitHub (Apr 26, 2025):

Also, I found that when user sign-in with passskey the current page is not updated and only when user manually refresh the page content is updated and user is signed in.

I was able to get around that by doing a router refresh:

void (await authClient.signIn.passkey({
	fetchOptions: {
		onSuccess: () => {
			router.push("/");
			router.refresh();
		},
	},

@leavism commented on GitHub (Apr 26, 2025): > Also, I found that when user sign-in with passskey the current page is not updated and only when user manually refresh the page content is updated and user is signed in. I was able to get around that by doing a router refresh: ```ts void (await authClient.signIn.passkey({ fetchOptions: { onSuccess: () => { router.push("/"); router.refresh(); }, }, ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#748