Documentation Index
Fetch the complete documentation index at: https://mintlify.com/MomenSherif/react-oauth/llms.txt
Use this file to discover all available pages before exploring further.
useGoogleLogin returns a login function that you can attach to any button or UI element. It supports two OAuth 2.0 flows:
- Implicit flow — returns an access token directly in the browser. Suitable for client-side-only apps.
- Authorization code flow — returns a one-time authorization code that your backend exchanges for access and refresh tokens.
Usage
Parameters
Common props
Selects the OAuth 2.0 flow.
implicit returns an access token directly; auth-code returns an authorization code for backend exchange.Callback fired after a successful authorization. Receives a
TokenResponse for the implicit flow or a CodeResponse for the auth-code flow.Callback fired when the authorization request fails with an OAuth error.
Callback fired for non-OAuth errors such as a popup failing to open or being closed before a response is returned.
A space-delimited list of OAuth scopes to request. By default,
openid profile email are always included.When
false, disables more granular Google Account permissions for clients created before 2019. Has no effect for newer clients.An email address hint for the target user. Corresponds to the
login_hint parameter in OpenID Connect.Hint for the Google Workspace domain the user belongs to. Corresponds to the
hd parameter in OpenID Connect.When
true, uses only the scopes specified in scope without prepending the default openid profile email scopes.Implicit flow props
These props apply only whenflow is 'implicit' (the default).
A space-delimited list of prompts to present the user.
Not recommended. An opaque string your application uses to maintain state between the authorization request and the server’s response.
Authorization code flow props
These props apply only whenflow is 'auth-code'.
The UX mode for the authorization flow.
popup opens a consent popup; redirect navigates the user to the consent page.Required when
ux_mode is redirect. Must exactly match one of the authorized redirect URIs configured in the Google API Console. Ignored by popup UX.Recommended for redirect UX. An opaque string your application uses to maintain state between the authorization request and the server’s response.
When
true, prompts the user to select a Google account even if they are already signed in.Return value
useGoogleLogin returns a login function.
- Implicit flow:
(overrideConfig?: OverridableTokenClientConfig) => void - Auth-code flow:
() => void
overrideConfig object when calling login() to override prompt, enable_serial_consent, hint, or state for that specific invocation.
Response types
TokenResponse (implicit flow)
The object passed toonSuccess when using the implicit flow:
The OAuth 2.0 access token.
The lifetime of the access token in seconds.
The token type. Always
Bearer.A space-delimited list of scopes granted by the user.
The prompt value that was used from the configuration.
The hosted Workspace domain the signed-in user belongs to.
The state string passed in the authorization request.
CodeResponse (auth-code flow)
The object passed toonSuccess when using the auth-code flow:
The one-time authorization code. Exchange this on your backend for access and refresh tokens.
A space-delimited list of scopes granted by the user.
The state string passed in the authorization request.
The authorization code can only be used once. Exchange it server-side using your OAuth client secret.

