feat(registry): add Google Sign-In script#573
Conversation
- Add useScriptGoogleSignIn composable with full GIS API support - One Tap, personalized button, and automatic sign-in flows - FedCM API support (Privacy Sandbox, mandatory Aug 2025) - Moment notifications for tracking One Tap display state - Comprehensive TypeScript types for all GIS interfaces - Interactive docs demo with live sign-in testing - E2E test and playground example Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
| } | ||
|
|
||
| export const GoogleSignInOptions = object({ | ||
| clientId: string(), |
There was a problem hiding this comment.
The clientId field in the GoogleSignInOptions schema is marked as required, but the documented pattern for registry-based script loading doesn't provide it to the composable, causing validation errors in development mode.
View Details
📝 Patch Details
diff --git a/docs/content/scripts/utility/google-sign-in.md b/docs/content/scripts/utility/google-sign-in.md
index 152d7ac..25f1787 100644
--- a/docs/content/scripts/utility/google-sign-in.md
+++ b/docs/content/scripts/utility/google-sign-in.md
@@ -123,7 +123,7 @@ You can configure the Google Sign-In script with the following options:
```ts
export const GoogleSignInOptions = object({
- clientId: string(),
+ clientId: optional(string()),
autoSelect: optional(boolean()),
context: optional(union([literal('signin'), literal('signup'), literal('use')])),
useFedcmForPrompt: optional(boolean()),
diff --git a/src/runtime/registry/google-sign-in.ts b/src/runtime/registry/google-sign-in.ts
index 696b7b3..a72e39e 100644
--- a/src/runtime/registry/google-sign-in.ts
+++ b/src/runtime/registry/google-sign-in.ts
@@ -107,7 +107,7 @@ export interface GoogleSignInApi {
}
export const GoogleSignInOptions = object({
- clientId: string(),
+ clientId: optional(string()),
// Auto-select credentials if only one is available
autoSelect: optional(boolean()),
// Context for One Tap (signin, signup, or use)
Analysis
Missing optional() wrapper on clientId field in GoogleSignInOptions schema
What fails: In src/runtime/registry/google-sign-in.ts, the clientId field in GoogleSignInOptions is defined as string() (required). When following the documented pattern of using googleSignIn: true in nuxt.config.ts with environment variable-based configuration, the composable receives an empty object {}. This causes schema validation to fail in development mode because clientId is marked required but not provided.
How to reproduce:
// nuxt.config.ts
export default defineNuxtConfig({
scripts: {
registry: {
googleSignIn: true, // No clientId provided here
}
},
runtimeConfig: {
public: {
scripts: {
googleSignIn: {
clientId: '', // Will be set via NUXT_PUBLIC_SCRIPTS_GOOGLE_SIGN_IN_CLIENT_ID
},
},
},
},
})Running the app in development mode generates: Invalid key: Expected "clientId" but received undefined when schema validation is triggered (line 143 of google-sign-in.ts: schema: import.meta.dev ? GoogleSignInOptions : undefined).
Result: Validation error appears in development when following the documented registry pattern with environment variables.
Expected: Schema validation should pass with empty object, as clientId can be provided externally (via runtime config, environment variables, or to accounts.id.initialize() separately). Made clientId optional in the schema by wrapping with optional() to match the actual use case where clientId may be provided through other configuration sources.
Fix: Changed clientId: string() to clientId: optional(string()) in:
src/runtime/registry/google-sign-in.ts(line 110)docs/content/scripts/utility/google-sign-in.md(line 126)
This aligns with the documented pattern in google-sign-in.md which shows googleSignIn: true without providing clientId in the config object.
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
🔗 Linked issue
#381
❓ Type of change
📚 Description
Adds Google Sign-In (Google Identity Services) as a registry script with:
useScriptGoogleSignIncomposable with full GIS API supportrenderButton