[Google one tap sign-in plugin] Binding the call of authClient.oneTap() with whether to insert the GSI script imposes some limitations in practical applications #1728

Closed
opened 2026-03-13 08:59:04 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @ItsRyanWu on GitHub (Aug 17, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Add the One Tap plugin but don't call authClient.oneTap() in code, then try to render the Google sign in button

Current vs. Expected behavior

I found the GSI script won't be inserted into HTML unless calling the method authClient.oneTap(), this might be nice to reduce unnecessary network bandwidth, however have you thought about a scenario where I don't need to call the function for now, but I need the GSI script to be loaded to render the Google sign in button on page?

Also the hidden behavior I mentioned above wasn't mentioned on doc, which caused me being stuck for a while, I thought there was a bug that the OneTap Plugin wouldn't insert the GSI script.

What version of Better Auth are you using?

1.2.8

System info

System:
    OS: macOS 15.6
    CPU: (14) arm64 Apple M3 Max
    Memory: 803.64 MB / 96.00 GB
    Shell: 5.9 - /bin/zsh
  Browsers:
    Chrome: 139.0.7258.128
    Safari: 18.6

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

Client

Auth config (if applicable)

oneTapClient({
			clientId: process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID,
			// Optional client configuration:
			autoSelect: true,
			cancelOnTapOutside: false,
			context: "signin",
			uxMode: "popup",
			additionalOptions: {
				use_fedcm_for_prompt: true,
				use_fedcm_for_button: true,
				itp_support: true,
				button_auto_select: true,
			},
			// Configure prompt behavior and exponential backoff:
			promptOptions: {
				baseDelay: 300, // Base delay in ms (default: 1000)
				maxAttempts: 5, // Maximum number of attempts before triggering onPromptNotification (default: 5)
			},
		}),

Additional context

No response

Originally created by @ItsRyanWu on GitHub (Aug 17, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Add the One Tap plugin but don't call `authClient.oneTap()` in code, then try to render the Google sign in button ### Current vs. Expected behavior I found the GSI script won't be inserted into HTML unless calling the method `authClient.oneTap()`, this might be nice to reduce unnecessary network bandwidth, however have you thought about a scenario where I don't need to call the function for now, but I need the GSI script to be loaded to render the Google sign in button on page? Also the hidden behavior I mentioned above wasn't mentioned on doc, which caused me being stuck for a while, I thought there was a bug that the OneTap Plugin wouldn't insert the GSI script. ### What version of Better Auth are you using? 1.2.8 ### System info ```bash System: OS: macOS 15.6 CPU: (14) arm64 Apple M3 Max Memory: 803.64 MB / 96.00 GB Shell: 5.9 - /bin/zsh Browsers: Chrome: 139.0.7258.128 Safari: 18.6 ``` ### Which area(s) are affected? (Select all that apply) Client ### Auth config (if applicable) ```typescript oneTapClient({ clientId: process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID, // Optional client configuration: autoSelect: true, cancelOnTapOutside: false, context: "signin", uxMode: "popup", additionalOptions: { use_fedcm_for_prompt: true, use_fedcm_for_button: true, itp_support: true, button_auto_select: true, }, // Configure prompt behavior and exponential backoff: promptOptions: { baseDelay: 300, // Base delay in ms (default: 1000) maxAttempts: 5, // Maximum number of attempts before triggering onPromptNotification (default: 5) }, }), ``` ### Additional context _No response_
GiteaMirror added the plugin label 2026-03-13 08:59:04 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 17, 2025):

Hi @ItsRyanWu! I'm Dosu and I’m helping the better-auth team.

You've identified a real limitation: the Better Auth One Tap plugin only loads the Google Identity Services (GSI) script when you call authClient.oneTap(), and there's currently no documented or supported way to load the script independently for use cases like rendering the Google sign-in button without triggering One Tap. This coupling is not mentioned in the docs, which has led to confusion for other users as well [docs].

The technical reason is that script injection is encapsulated within the oneTap() logic, likely to optimize bandwidth and avoid unnecessary network requests, but it does mean you can't proactively load the GSI script for other UI flows [code]. There isn't a built-in workaround, but you could manually inject the GSI script in your app if you need the button before calling oneTap().

Improving the documentation to clarify this behavior and adding an option to load the GSI script independently would help avoid confusion and make the plugin more flexible. This has been raised in user discussions and is a valid suggestion for future updates [issue].

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Aug 17, 2025): <!-- Greeting --> Hi @ItsRyanWu! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> You've identified a real limitation: the Better Auth One Tap plugin only loads the Google Identity Services (GSI) script when you call `authClient.oneTap()`, and there's currently no documented or supported way to load the script independently for use cases like rendering the Google sign-in button without triggering One Tap. This coupling is not mentioned in the docs, which has led to confusion for other users as well [[docs](https://github.com/better-auth/better-auth/blob/efa60af1c2d45a735ed397171bfca513b7e202ca/docs/content/docs/plugins/one-tap.mdx)]. The technical reason is that script injection is encapsulated within the `oneTap()` logic, likely to optimize bandwidth and avoid unnecessary network requests, but it does mean you can't proactively load the GSI script for other UI flows [[code](https://github.com/better-auth/better-auth/blob/efa60af1c2d45a735ed397171bfca513b7e202ca/packages/better-auth/src/plugins/one-tap/index.ts)]. There isn't a built-in workaround, but you could manually inject the GSI script in your app if you need the button before calling `oneTap()`. Improving the documentation to clarify this behavior and adding an option to load the GSI script independently would help avoid confusion and make the plugin more flexible. This has been raised in user discussions and is a valid suggestion for future updates [[issue](https://github.com/better-auth/better-auth/issues/1415)]. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/aa40fe6c-cee8-457d-93d4-20869a78126d?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/aa40fe6c-cee8-457d-93d4-20869a78126d?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/aa40fe6c-cee8-457d-93d4-20869a78126d?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/aa40fe6c-cee8-457d-93d4-20869a78126d?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/aa40fe6c-cee8-457d-93d4-20869a78126d?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/aa40fe6c-cee8-457d-93d4-20869a78126d?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/aa40fe6c-cee8-457d-93d4-20869a78126d?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/4053)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1728