Gathering detailed insights and metrics for @react-oauth/google
Gathering detailed insights and metrics for @react-oauth/google
Gathering detailed insights and metrics for @react-oauth/google
Gathering detailed insights and metrics for @react-oauth/google
react-google-login
A Google Login Component for React
@react-native-google-signin/google-signin
Google sign in for your react native applications
react-oauth-google
Google OAuth2 using Google Identity Services for React 🚀
google-oauth-gsi
A user-friendly API for GIS SDK, using the new [**Google Identity Services SDK**](https://developers.google.com/identity/gsi/web) 🚀
Google OAuth2 using the new Google Identity Services SDK for React 🚀
npm install @react-oauth/google
Typescript
Module System
Node Version
NPM Version
@react-oauth/google@0.12.2
Updated on May 07, 2025
@react-oauth/google@0.12.1
Updated on Nov 18, 2023
@react-oauth/google@0.12.0
Updated on Nov 18, 2023
@react-oauth/google@0.11.1
Updated on Jul 24, 2023
@react-oauth/google@0.11.0
Updated on Apr 26, 2023
@react-oauth/google@0.10.0
Updated on Apr 15, 2023
TypeScript (89.37%)
HTML (6.69%)
JavaScript (3.68%)
Shell (0.26%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1,247 Stars
88 Commits
150 Forks
8 Watchers
2 Branches
17 Contributors
Updated on Jul 15, 2025
Latest Version
0.12.2
Package Id
@react-oauth/google@0.12.2
Unpacked Size
77.11 kB
Size
10.57 kB
File Count
5
NPM Version
8.19.4
Node Version
16.20.2
Published on
May 07, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
4
Google OAuth2 using the new Google Identity Services SDK for React @react-oauth/google🚀
1$ npm install @react-oauth/google@latest 2 3# or 4 5$ yarn add @react-oauth/google@latest
https://react-oauth.vercel.app/
Add a personalized and customizable sign-up or sign-in button to your website.
Sign up new users with just one tap, without interrupting them with a sign-up screen. Users get a secure, token-based, passwordless account on your site, protected by their Google Account.
Sign users in automatically when they return to your site on any device or browser, even after their session expires.
OAuth 2.0 implicit and authorization code flows for web apps
The Google Identity Services JavaScript library helps you to quickly and safely obtain access tokens necessary to call Google APIs. Your web application, complete either the OAuth 2.0 implicit flow, or to initiate the authorization code flow which then finishes on your backend platform.
Key Point: Add both
http://localhost
andhttp://localhost:<port_number>
to the Authorized JavaScript origins box for local tests or development.
Configure your OAuth Consent Screen
Wrap your application with GoogleOAuthProvider
1import { GoogleOAuthProvider } from '@react-oauth/google'; 2 3<GoogleOAuthProvider clientId="<your_client_id>">...</GoogleOAuthProvider>;
1import { GoogleLogin } from '@react-oauth/google'; 2 3<GoogleLogin 4 onSuccess={credentialResponse => { 5 console.log(credentialResponse); 6 }} 7 onError={() => { 8 console.log('Login Failed'); 9 }} 10/>;
1import { useGoogleOneTapLogin } from '@react-oauth/google'; 2 3useGoogleOneTapLogin({ 4 onSuccess: credentialResponse => { 5 console.log(credentialResponse); 6 }, 7 onError: () => { 8 console.log('Login Failed'); 9 }, 10});
or
1import { GoogleLogin } from '@react-oauth/google'; 2 3<GoogleLogin 4 onSuccess={credentialResponse => { 5 console.log(credentialResponse); 6 }} 7 onError={() => { 8 console.log('Login Failed'); 9 }} 10 useOneTap 11/>;
If you are using one tap login, when logging user out consider this issue may happen, to prevent it call
googleLogout
when logging user out from your application.
1import { googleLogout } from '@react-oauth/google'; 2 3googleLogout();
auto_select
proptrue
1 2<GoogleLogin 3 ... 4 auto_select 5/> 6 7useGoogleOneTapLogin({ 8 ... 9 auto_select 10});
1import { useGoogleLogin } from '@react-oauth/google'; 2 3const login = useGoogleLogin({ 4 onSuccess: tokenResponse => console.log(tokenResponse), 5}); 6 7<MyCustomButton onClick={() => login()}>Sign in with Google 🚀</MyCustomButton>;
Requires backend to exchange code with access and refresh token.
1import { useGoogleLogin } from '@react-oauth/google'; 2 3const login = useGoogleLogin({ 4 onSuccess: codeResponse => console.log(codeResponse), 5 flow: 'auth-code', 6}); 7 8<MyCustomButton onClick={() => login()}>Sign in with Google 🚀</MyCustomButton>;
1import { hasGrantedAllScopesGoogle } from '@react-oauth/google'; 2 3const hasAccess = hasGrantedAllScopesGoogle( 4 tokenResponse, 5 'google-scope-1', 6 'google-scope-2', 7);
1import { hasGrantedAnyScopeGoogle } from '@react-oauth/google'; 2 3const hasAccess = hasGrantedAnyScopeGoogle( 4 tokenResponse, 5 'google-scope-1', 6 'google-scope-2', 7);
Required | Prop | Type | Description |
---|---|---|---|
✓ | clientId | string | Google API client ID |
nonce | string | Nonce applied to GSI script tag. Propagates to GSI's inline style tag | |
onScriptLoadSuccess | function | Callback fires on load gsi script success | |
onScriptLoadError | function | Callback fires on load gsi script failure |
Required | Prop | Type | Description |
---|---|---|---|
✓ | onSuccess | (response: CredentialResponse) => void | Callback fires with credential response after successfully login |
onError | function | Callback fires after login failure | |
type | standard | icon | Button type type | |
theme | outline | filled_blue | filled_black | Button theme | |
size | large | medium | small | Button size | |
text | signin_with | signup_with | continue_with | signin | Button text. For example, "Sign in with Google", "Sign up with Google" or "Sign in" | |
shape | rectangular | pill | circle | square | Button shape | |
logo_alignment | left | center | Google logo alignment | |
width | string | button width, in pixels | |
locale | string | If set, then the button language is rendered | |
useOneTap | boolean | Activate One-tap sign-up or not | |
promptMomentNotification | (notification: PromptMomentNotification) => void | PromptMomentNotification methods and description | |
cancel_on_tap_outside | boolean | Controls whether to cancel the prompt if the user clicks outside of the prompt | |
auto_select | boolean | Enables automatic selection on Google One Tap | |
ux_mode | popup | redirect | The Sign In With Google button UX flow | |
login_uri | string | The URL of your login endpoint | |
native_login_uri | string | The URL of your password credential handler endpoint | |
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 | |
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 | |
intermediate_iframe_close_callback | function | Overrides the default intermediate iframe behavior when users manually close One Tap | |
itp_support | boolean | Enables upgraded One Tap UX on ITP browsers | |
hosted_domain | string | If your application knows the Workspace domain the user belongs to, use this to provide a hint to Google. For more information, see the hd field in the OpenID Connect docs | |
use_fedcm_for_prompt | boolean | Allow the browser to control user sign-in prompts and mediate the sign-in flow between your website and Google. | |
use_fedcm_for_button | boolean | Enable FedCM Button flow. |
Required | Prop | Type | Description |
---|---|---|---|
flow | implicit | auth-code | Two flows, implicit and authorization code are discussed. Both return an access token suitable for use with Google APIs | |
onSuccess | (response: TokenResponse|CodeResponse) => void | Callback fires with response (token | code) based on flow selected after successfully login | |
onError | (errorResponse: {error: string; error_description?: string,error_uri?: string}) => void | Callback fires after login failure | |
onNonOAuthError | (nonOAuthError: NonOAuthError) => void | Some non-OAuth errors, such as the popup window is failed to open or closed before an OAuth response is returned. popup_failed_to_open | popup_closed | unknown | |
scope | string | A space-delimited list of scopes that are approved by the user | |
enable_serial_consent | boolean | defaults to true. If set to false, more granular Google Account permissions will be disabled for clients created before 2019. No effect for newer clients, since more granular permissions is always enabled for them. | |
hint | string | If your application knows which user should authorize the request, it can use this property to provide a hint to Google. The email address for the target user. For more information, see the login_hint field in the OpenID Connect docs | |
hosted_domain | string | If your application knows the Workspace domain the user belongs to, use this to provide a hint to Google. For more information, see the hd field in the OpenID Connect docs |
Required | Prop | Type | Description |
---|---|---|---|
prompt | '' | none | consent | select_account | defaults to 'select_account'. A space-delimited, case-sensitive list of prompts to present the user | |
state | string | Not recommended. Specifies any string value that your application uses to maintain state between your authorization request and the authorization server's response |
Required | Prop | Type | Description |
---|---|---|---|
ux_mode | popup | redirect | The UX mode to use for the authorization flow. By default, it will open the consent flow in a popup. Valid values are popup and redirect | |
redirect_uri | string | Required for redirect UX. Determines where the API server redirects the user after the user completes the authorization flow The value must exactly match one of the authorized redirect URIs for the OAuth 2.0 client which you configured in the API Console and must conform to our Redirect URI validation rules. The property will be ignored by the popup UX | |
state | string | Recommended for redirect UX. Specifies any string value that your application uses to maintain state between your authorization request and the authorization server's response | |
select_account | boolean | defaults to 'false'. Boolean value to prompt the user to select an account |
Required | Prop | Type | Description |
---|---|---|---|
✓ | onSuccess | (response: CredentialResponse) => void | Callback fires with credential response after successfully login |
onError | function | Callback fires after login failure | |
promptMomentNotification | (notification: PromptMomentNotification) => void | PromptMomentNotification methods and description | |
cancel_on_tap_outside | boolean | Controls whether to cancel the prompt if the user clicks outside of the prompt | |
hosted_domain | string | If your application knows the Workspace domain the user belongs to, use this to provide a hint to Google. For more information, see the hd field in the OpenID Connect docs | |
disabled | boolean | Controls whether to cancel the popup in cases such as when the user is already logged in | |
use_fedcm_for_prompt | boolean | Allow the browser to control user sign-in prompts and mediate the sign-in flow between your website and Google. | |
use_fedcm_for_button | boolean | Enable FedCM Button flow. |
No vulnerabilities found.
No security vulnerabilities found.