Google OAuth2 using the new Google Identity Services SDK for React π
See the codeReact OAuth is a collection of production-ready OAuth2 libraries for React applications. Each package is designed to be simple, type-safe, and easy to integrate into your projects.
| Package | Description | NPM |
|---|---|---|
| @react-oauth/google | Google OAuth2 using the new Google Identity Services SDK | |
| @react-oauth/github | Modern React hook for GitHub OAuth authentication |
npm install @react-oauth/google
# or
yarn add @react-oauth/google
Basic Usage:
import { GoogleOAuthProvider, GoogleLogin } from '@react-oauth/google';
function App() {
return (
<GoogleOAuthProvider clientId="<your_client_id>">
<GoogleLogin
onSuccess={credentialResponse => {
console.log(credentialResponse);
}}
onError={() => {
console.log('Login Failed');
}}
/>
</GoogleOAuthProvider>
);
}
Features:
npm install @react-oauth/github
# or
yarn add @react-oauth/github
Basic Usage:
import { useGitHubLogin } from '@react-oauth/github';
function LoginButton() {
const { initiateGitHubLogin, isLoading } = useGitHubLogin({
clientId: 'your-github-client-id',
redirectUri: 'http://localhost:3000/callback',
onSuccess: response => {
console.log('Authorization code:', response.code);
// Exchange code for access token on your backend
},
onError: error => {
console.error('Authentication failed:', error);
},
});
return (
<button onClick={initiateGitHubLogin} disabled={isLoading}>
{isLoading ? 'Loading...' : 'Sign in with GitHub'}
</button>
);
}
Features:
Check out the live demo to see the Google OAuth package in action:
π https://react-oauth.vercel.app/ (Google OAuth only)
Contributions are welcome! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
Made with β€οΈ for the React community
GitHub β’ Issues β’ @react-oauth/google β’ @react-oauth/github
1,267 followers Β· starred May 2022
37 followers Β· starred Jun 2022
80 followers Β· starred Aug 2022
101 followers Β· starred Feb 2026
Google OAuth2 using the new Google Identity Services SDK for React π
See the codeReact OAuth is a collection of production-ready OAuth2 libraries for React applications. Each package is designed to be simple, type-safe, and easy to integrate into your projects.
| Package | Description | NPM |
|---|---|---|
| @react-oauth/google | Google OAuth2 using the new Google Identity Services SDK | |
| @react-oauth/github | Modern React hook for GitHub OAuth authentication |
npm install @react-oauth/google
# or
yarn add @react-oauth/google
Basic Usage:
import { GoogleOAuthProvider, GoogleLogin } from '@react-oauth/google';
function App() {
return (
<GoogleOAuthProvider clientId="<your_client_id>">
<GoogleLogin
onSuccess={credentialResponse => {
console.log(credentialResponse);
}}
onError={() => {
console.log('Login Failed');
}}
/>
</GoogleOAuthProvider>
);
}
Features:
npm install @react-oauth/github
# or
yarn add @react-oauth/github
Basic Usage:
import { useGitHubLogin } from '@react-oauth/github';
function LoginButton() {
const { initiateGitHubLogin, isLoading } = useGitHubLogin({
clientId: 'your-github-client-id',
redirectUri: 'http://localhost:3000/callback',
onSuccess: response => {
console.log('Authorization code:', response.code);
// Exchange code for access token on your backend
},
onError: error => {
console.error('Authentication failed:', error);
},
});
return (
<button onClick={initiateGitHubLogin} disabled={isLoading}>
{isLoading ? 'Loading...' : 'Sign in with GitHub'}
</button>
);
}
Features:
Check out the live demo to see the Google OAuth package in action:
π https://react-oauth.vercel.app/ (Google OAuth only)
Contributions are welcome! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
Made with β€οΈ for the React community
GitHub β’ Issues β’ @react-oauth/google β’ @react-oauth/github
1,267 followers Β· starred May 2022
37 followers Β· starred Jun 2022
80 followers Β· starred Aug 2022
101 followers Β· starred Feb 2026