react-google-login-button

Renders the Google Login button that will trigger Google's OAuth2 process. Highly customizable as per Google's documentation.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
react-google-login-button
011.0.25 years ago5 years agoMinified + gzip package size for react-google-login-button in KB

Readme

React Google Login Button
This component renders the Google Login button as per the Google docs. Only difference is it is adapted for use in a React component.
Check out the Demo!.

Parameters

| Key | Required / optional | Type | Default | |-----|---------------------|------|---------| | googleClientId | required | string | - | | onLoginSuccess | required | function | - | | onLoginFailure | required | function | - | | width | optional | number | 140 | | height | optional | number | 40 | | longTitle | optional | boolean | false | | theme | optional | string: 'light' / 'dark' | light |

Usage

Snippet:
import GoogleLoginButton from 'react-google-login-button'

[...]

  render() {
    return (
      <GoogleLoginButton
        googleClientId='YOUR_GOOGLE_CLIENT_ID_HERE'
        onLoginSuccess={(googleUser) => {
          console.log('Replace this function to start using this information');
          console.log('Google User:', googleUser.getBasicProfile());
          console.log('ID token:', googleUser.getAuthResponse().id_token);
        })}
        onLoginFailure={() => console.log('Login failed')}
        width={140}
        height={40}
        longTitle={false}
        theme="light"
      />    
    );
  }
  
[...]

References

Gapi reference Button rendering params reference Use the ID token for authentication on your backend