Skip to main content

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.

@react-oauth/google is a React library that wraps Google’s Google Identity Services (GIS) SDK, giving you production-ready components and hooks for authenticating users with Google in any React application.

Why use this library?

Google deprecated the older Google Sign-In JavaScript Platform Library (platform.js) in favor of the new Google Identity Services SDK. The new SDK has a different API surface — @react-oauth/google wraps it so you don’t have to deal with the low-level GIS API directly. Key differences from the old react-google-login package:
Old (react-google-login)New (@react-oauth/google)
Underlying SDKplatform.js (deprecated)Google Identity Services
Sign-in modelPersistent sessionCredential/token per flow
One-tap supportNoYes
Authorization code flowNoYes
FedCM supportNoYes
Maintenance statusUnmaintainedActive

Key features

Sign In With Google

Render Google’s official sign-in button with full customization: size, shape, theme, text, and locale. Renders through the GIS SDK for compliance.

One-tap & automatic sign-in

Prompt returning users with a One-tap overlay or sign them in automatically when they revisit. Enable with a single prop.

Custom button flows

Use useGoogleLogin to trigger implicit or authorization code flows from any UI element you build yourself.

Authorization code flow

Initiate the server-side auth code flow for backend token exchange, with full support for redirect and popup UX modes.

TypeScript first

Every component, hook, and callback is fully typed. Types for CredentialResponse, TokenResponse, CodeResponse, and more are all exported.

Automatic SDK loading

Wrap your app with GoogleOAuthProvider and the Google Identity Services script is loaded automatically — no manual <script> tag required.

How it works

GoogleOAuthProvider loads the GIS SDK script (https://accounts.google.com/gsi/client) automatically when it mounts. All child components and hooks read the clientId and script-loaded status from React context, so you only configure your client ID once.
You do not need to add the Google Identity Services script tag to your HTML. GoogleOAuthProvider handles this for you via the useLoadGsiScript hook internally.

Exported API

ExportTypeDescription
GoogleOAuthProviderComponentContext provider. Loads the GIS SDK and supplies clientId to all children.
GoogleLoginComponentRenders the official Sign In With Google button. Supports One-tap via useOneTap prop.
useGoogleLoginHookReturns a login trigger function for implicit or authorization code flows.
useGoogleOneTapLoginHookTriggers the One-tap prompt imperatively from any component.
googleLogoutFunctionRevokes the session with Google Identity Services.
hasGrantedAllScopesGoogleFunctionChecks whether all requested scopes were granted in a token response.
hasGrantedAnyScopeGoogleFunctionChecks whether at least one requested scope was granted in a token response.
useGoogleOAuthHookAccess clientId and scriptLoadedSuccessfully from context.

Installation

npm install @react-oauth/google@latest
Requirements: React 16.8 or later and react-dom 16.8 or later.

Next steps

Quickstart

Add Google sign-in to your React app in minutes with a step-by-step guide.

API reference

Full props and type definitions for every component and hook.

Build docs developers (and LLMs) love