# @rheasmith/react-google-one-tap-login

> React wrapper for google one tap authentication

Latest version **0.1.3** (published 2023-02-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install @rheasmith/react-google-one-tap-login
pnpm add @rheasmith/react-google-one-tap-login
yarn add @rheasmith/react-google-one-tap-login
bun add @rheasmith/react-google-one-tap-login
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2023-02-10 |
| First published | 2023-02-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 52.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Rhea |
| Maintainers | rheasmith |
| Keywords | one, tap, react, login, hooks, google, google, wrapper, reactjs, one tap login, authentication, react-google-one-tap, react-google-one-tap-login |

## Links

- npm: https://www.npmjs.com/package/@rheasmith/react-google-one-tap-login
- Repository: https://github.com/rheaninja/react-google-one-tap-login-with-button
- Issues: https://github.com/rheaninja/react-google-one-tap-login-with-button/issues
- npm.io page: https://npm.io/package/@rheasmith/react-google-one-tap-login

## Recent versions

- 0.1.3 (latest) — 2023-02-10
- 0.1.2 — 2023-02-10
- 0.1.1 — 2023-02-10

## README

# React - Google One Tap Login

React wrapper for google one tap authentication

## Install

```
npm install @rheasmith/react-google-one-tap-login
```

OR

```
yarn add @rheasmith/react-google-one-tap-login
```

## How to use

## As a Hook

```js
import { useGoogleOneTapLogin } from '@rheasmith/react-google-one-tap-login';

useGoogleOneTapLogin({
    onError: error => console.log(error),
    onSuccess: response => console.log(response),
    googleAccountConfigs: {
      client_id: // Your google client id here !!!
    },
  });
```

## As a Component

```js
import React from 'react';
import ReactDOM from 'react-dom';
import GoogleOneTapLogin from '@rheasmith/react-google-one-tap-login';

ReactDOM.render(
  <GoogleOneTapLogin onError={(error) => console.log(error} onSuccess={(response) => console.log(response} googleAccountConfigs={{ client_id: // Your google client id here !!! }} />,
  document.getElementById('root')
);
```

## Add Login Button use id="googlButton"

```js
import React from 'react';
import ReactDOM from 'react-dom';
import GoogleOneTapLogin from '@rheasmith/react-google-one-tap-login';

ReactDOM.render(
  <><div id="googleButton"></div></>,
  document.getElementById('root')
);
```


## Props

| Name                   | Type     | Required |                                                         Description                                                          |
| ---------------------- | -------- | :------: | :--------------------------------------------------------------------------------------------------------------------------: |
| disabled               | boolean  |  false   |                                                   Disable the login prompt                                                   |
| onError                | callback |  false   |                                                       onError : Error                                                        | null |
| onSuccess              | callback |  false   |                                        onSuccess : GoogleEndpointResponse (See below)                                        |
| disableCancelOnUnmount | boolean  |  false   |                                       Disable cancelation of one tap login on unmount                                        |
| googleAccountConfigs   | object   |   true   | [Google One Tap JS API Reference](https://developers.google.com/identity/one-tap/web/reference/js-reference#IdConfiguration) |

#### \*client_id is required in googleAccountConfigs

## Google EndPoint Response

[More details](https://developers.google.com/identity/sign-in/web/backend-auth#calling-the-tokeninfo-endpoint)
| Name | Type |
|----------------|--------|
| iss | string |
| sup | string |
| azp | string |
| aud | string |
| iat | string |
| exp | string |
| name | string |
| email | string |
| local | string |
| picture | string |
| given_name | string |
| family_name | string |
| email_verified | string |

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