This guide walks you through the minimum setup to render a working Sign In With Google button in your React app.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.
Get your Google API client ID
Go to the Google Cloud Console API dashboard and create or select a project. Then:
- Navigate to Credentials and click Create credentials > OAuth client ID.
- Select Web application as the application type.
- Add your app’s origin to Authorized JavaScript origins.
- Copy the generated Client ID — you’ll use it in step 3.
Configure your OAuth consent screen
Before Google allows sign-in, you must configure what users see when they authenticate.
- In the Google Cloud Console, go to OAuth consent screen.
- Choose External (for apps available to any Google user) or Internal (for Google Workspace organizations).
- Fill in the required fields: app name, user support email, and developer contact.
- Add any scopes your app needs. For basic sign-in, the default
openid,profile, andemailscopes are sufficient. - Save and continue.
While your app is in Testing status, only users you explicitly add as test users can sign in. Publish the app when you’re ready for public access.
Wrap your app with GoogleOAuthProvider
GoogleOAuthProvider loads the Google Identity Services SDK and makes your client ID available to all components inside it. Render it at the root of your app (or at least above any component that uses Google sign-in).YOUR_CLIENT_ID with the client ID you copied in step 1.Add the GoogleLogin button
Render the When the user clicks the button and completes sign-in, The
GoogleLogin component anywhere inside GoogleOAuthProvider. Pass onSuccess to handle the credential response and onError for failures.onSuccess fires with a CredentialResponse object:credential field is a JWT ID token. Decode it on your backend to verify the user’s identity and extract their profile information (name, email, picture, etc.).Cross-Origin Opener Policy
If you use the default popup UX mode, set the following HTTP response header on your page to prevent a blank popup window issue:next.config.js:
What’s next
Customize the sign-in button
Control the button’s size, shape, theme, text, and locale.
Build a custom button
Use
useGoogleLogin to trigger sign-in from your own button or UI element.One-tap sign-in
Prompt returning users to sign in with a single tap using
useGoogleOneTapLogin.API reference
Full props and type definitions for
GoogleOAuthProvider, GoogleLogin, and all hooks.
