
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
react-oauth2
Advanced tools
    with TypeScript support. Zero dependencies, fully customizable, and built with security in mind.
# npm
npm install react-oauth2
# yarn
yarn add react-oauth2
# pnpm
pnpm add react-oauth2
import { FacebookOauth2, GoogleOauth2 } from 'react-oauth2';
function App() {
const handleCallback = (error: Error, response: OAuthResponse) => {
if (error) {
// Handle error
return;
}
const {profile} = response;
// Handle successful login
};
return (
<div>
<GoogleOauth2
clientId="your-google-client-id"
clientSecret="your-google-client-secret"
redirectUri="http://localhost:3000/auth/google/callback"
scope={['openid', 'email', 'profile']}
callback={handleCallback}
>
Continue with Google
</GoogleOauth2>
<FacebookOauth2
clientId="your-facebook-client-id"
clientSecret="your-facebook-client-secret"
redirectUri="http://localhost:3000/auth/facebook/callback"
scope="email,public_profile"
callback={handleCallback}
>
Continue with Facebook
</FacebookOauth2>
</div>
);
}
| Prop | Type | Required | Description |
|---|---|---|---|
| clientId | string | Yes | Your Google OAuth 2.0 client ID |
| clientSecret | string | Yes | Your Google OAuth 2.0 client secret |
| redirectUri | string | Yes | The URI to redirect to after authentication |
| scope | string[] | No | Array of permission scopes |
| callback | (error: Error, response: OAuthResponse) => void | Yes | callback |
| className | string | No | Custom CSS class |
| style | CSSProperties | No | Custom styles |
| children | ReactNode | Yes | Button content |
| Prop | Type | Required | Description |
|---|---|---|---|
| clientId | string | Yes | Your Facebook App ID |
| clientSecret | string | Yes | Your Facebook App Secret |
| redirectUri | string | Yes | The URI to redirect to after authentication |
| scope | string | No | Comma-separated permission scopes |
| callback | (error: Error, response: OAuthResponse) => void | Yes | callback |
| className | string | No | Custom CSS class |
| style | CSSProperties | No | Custom styles |
| children | ReactNode | Yes | Button content |
<GoogleButton
className="custom-google-button"
style={{
backgroundColor: '#4285f4',
color: 'white',
padding: '12px 24px',
borderRadius: '4px',
}}
>
<GoogleIcon className="custom-icon" />
Sign in with Google
</GoogleButton>
// .env
REACT_APP_GOOGLE_CLIENT_ID=your-google-client-id
REACT_APP_GOOGLE_CLIENT_SECRET=your-google-client-secret
REACT_APP_FACEBOOK_CLIENT_ID=your-facebook-client-id
REACT_APP_FACEBOOK_CLIENT_SECRET=your-facebook-client-secret
import type {OAuthResponse, OAuthError} from 'react-oauth2';
const handleCallback = (error: Error, response: OAuthResponse) => {
if (error) {
// Handle error
return;
}
const {profile} = response;
// Handle successful login
};
The full source code for this package is available on GitHub.
We welcome contributions! Please see our Contributing Guide for details.
MIT © maxifjaved
react, oauth, oauth2, social-login, google-login, facebook-login, react-component, typescript, authentication, social-authentication, google-oauth, facebook-oauth, react18, social-media-login, oauth2-client, react-oauth, social-signin, google-signin, facebook-signin, react-social-login
Made with ❤️ by @maxifjaved
FAQs
   
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.