# google-login-react

> Login using the new Google Authentication SDK

Latest version **0.2.17** (published 2022-11-23) · 0 weekly downloads

## Install

```sh
npm install google-login-react
pnpm add google-login-react
yarn add google-login-react
bun add google-login-react
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.17 |
| Published | 2022-11-23 |
| First published | 2022-11-21 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 30.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | alejordanze |
| Maintainers | alejordanze |
| Keywords | react, google, auth, oauth |

## Links

- npm: https://www.npmjs.com/package/google-login-react
- Repository: https://github.com/alejordanze/google-signin-react
- Homepage: https://github.com/alejordanze/google-signin-react#readme
- Issues: https://github.com/alejordanze/google-signin-react/issues
- npm.io page: https://npm.io/package/google-login-react

## Alternatives

- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads
- [escher-request](https://npm.io/package/escher-request.md) — 545 weekly downloads

## Recent versions

- 0.2.17 (latest) — 2022-11-23
- 0.2.16 — 2022-11-23
- 0.2.15 — 2022-11-23
- 0.2.14 — 2022-11-23
- 0.2.13 — 2022-11-23
- 0.2.12 — 2022-11-23
- 0.2.11 — 2022-11-23
- 0.2.10 — 2022-11-23
- 0.2.8 — 2022-11-22
- 0.2.7 — 2022-11-22
- 0.2.6 — 2022-11-22
- 0.2.5 — 2022-11-22
- 0.2.4 — 2022-11-22
- 0.2.3 — 2022-11-22
- 0.2.2 — 2022-11-22
- … 12 more at https://npm.io/package/google-login-react/versions

## README

# Google Login React

Google Login using the new [**Google Authentication SDK**](https://developers.google.com/identity/gsi/web)

## Install

```sh
$ npm install google-login-react

# or

$ yarn add google-login-react
```

## Usage

### Usage with default button

```jsx
import { GoogleLogin } from 'google-login-react-ts';

const App = () => {
  return (
    <GoogleLogin
      clientId='<your_client_id>'
      onSuccess={(res) => console.log(res)}
      onError={(err) => console.log(err)}
    />
  );
}
```

### Usage with custom button

```jsx
import { GoogleLogin } from 'google-signin-react-ts';

const App = () => {
  return (
    <GoogleLogin
      clientId='<your_client_id>'
      onSuccess={(res) => console.log(res)}
      onError={(err) => console.log(err)}
      containerClass="<your_custom_class>"
    >
      <button>Google Login</button>
    </GoogleLogin>
  )
}
```

### Usage with render

```jsx
import { GoogleLogin } from 'google-signin-react-ts';

const App = () => {
  return (
    <GoogleLogin
      clientId='<your_client_id>'
      onSuccess={(res) => console.log(res)}
      onError={(err) => console.log(err)}
      containerClass="<your_custom_class>"
      render={(renderProps) => (
        <button onClick={renderProps.onClick}>Google Login</button>
      )}
    />
  )
}
```

## API

### GoogleLogin

| Required  | Property                | Type       | Description                                                                 |
| :--------: | ------------------- | ---------- | --------------------------------------------------------------------------- |
|  ✅  | clientId            | `string`   | Google Project Client ID |
|| containerClass | `boolean` | Container className                                  |
|  ✅  | onSuccess   | `(response: GoogleResponse) => void` | Callback fires after successful login                      |
|| onError   | `(response: Error) => void` | Callback fires after unsuccessful login                      |
|| scope   | `string` | Google [scopes](https://developers.google.com/identity/protocols/oauth2/scopes)                          |
|| children   | `element` | Element that replaces default button              |
|| render   | `({ onClick }) => void` | Render JSX Element passing onClick function      |
|| userInfoFetchURL   | `string` \| [default](https://www.googleapis.com/oauth2/v3/userinfo?grant_type=authorization_token) | URL to retrive Google User info       |

## Response

### Google Successful Response

```json
  {
    "email": "...",
    "email_verified": "...",
    "family_name": "...",
    "given_name": "...",
    "locale": "...",
    "name": "...",
    "picture": "...",
    "sub": "..."
  }
```

| Property                | Type       | Description                                                                 |
| ------------------- | ---------- | --------------------------------------------------------------------------- |
| email            | `string`   | Google user email|
| email_verified | `boolean` | Google user email is verified                                  |
| family_name   | `string` | Google user family name                            |
| given_name   | `string` | Google user given name                            |
| locale   | `string` | Google user locale                           |
| name   | `string` | Google user name                           |
| picture   | `string` | Google user picture URL                           |
| sub   | `string` | Google user sub ID                           |

---
_Source: https://npm.io/package/google-login-react · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
