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"
/>
);
}
[...]