diff --git a/.changeset/tiny-singers-swim.md b/.changeset/tiny-singers-swim.md new file mode 100644 index 0000000..dcd6d10 --- /dev/null +++ b/.changeset/tiny-singers-swim.md @@ -0,0 +1,5 @@ +--- +'@react-oauth/google': minor +--- + +Added natively supported state property to GoogleLogin component diff --git a/README.md b/README.md index 3c2db68..4877748 100644 --- a/README.md +++ b/README.md @@ -221,6 +221,7 @@ const hasAccess = hasGrantedAnyScopeGoogle( | | native_callback | `(response: { id: string; password: string }) => void` | The JavaScript password credential handler function name | | | prompt_parent_id | `string` | The DOM ID of the One Tap prompt container element | | | nonce | `string` | A random string for ID tokens | +| | state | `string` | This string returns with the ID token | | | context | `signin` \| `signup` \| `use` | The title and words in the One Tap prompt | | | state_cookie_domain | `string` | If you need to call One Tap in the parent domain and its subdomains, pass the parent domain to this attribute so that a single shared cookie is used | | | allowed_parent_origin | `string` \| `string[]` | The origins that are allowed to embed the intermediate iframe. One Tap will run in the intermediate iframe mode if this attribute presents | diff --git a/packages/@react-oauth/google/src/GoogleLogin.tsx b/packages/@react-oauth/google/src/GoogleLogin.tsx index dc8777b..8f16dac 100644 --- a/packages/@react-oauth/google/src/GoogleLogin.tsx +++ b/packages/@react-oauth/google/src/GoogleLogin.tsx @@ -35,6 +35,7 @@ export default function GoogleLogin({ width, locale, click_listener, + state, containerProps, ...props }: GoogleLoginProps) { @@ -80,6 +81,7 @@ export default function GoogleLogin({ width, locale, click_listener, + state, }); if (useOneTap) diff --git a/packages/@react-oauth/google/src/types/index.ts b/packages/@react-oauth/google/src/types/index.ts index f880f66..3ce8672 100644 --- a/packages/@react-oauth/google/src/types/index.ts +++ b/packages/@react-oauth/google/src/types/index.ts @@ -100,6 +100,8 @@ export interface GsiButtonConfiguration { locale?: string; /** If set, this [function](https://developers.google.com/identity/gsi/web/reference/js-reference#click_listener) will be called when the Sign in with Google button is clicked. */ click_listener?: () => void; + /** If set, this [string](https://developers.google.com/identity/gsi/web/reference/js-reference#state) returns with the ID token. */ + state?: string; } export interface PromptMomentNotification {