# react-native-recaptcha-v2

> Implement Google recaptcha v2 in React Native (both Android an iOS)

Latest version **1.0.2** (published 2020-01-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-recaptcha-v2
pnpm add react-native-recaptcha-v2
yarn add react-native-recaptcha-v2
bun add react-native-recaptcha-v2
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-01-07 |
| First published | 2020-01-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | xuho |
| Maintainers | ehbasouri |
| Keywords | react-native, google, recaptcha, captcha, mobile, ios, android |

## Links

- npm: https://www.npmjs.com/package/react-native-recaptcha-v2
- Repository: https://github.com/ehbasouri/react-native-recaptcha-v2
- Homepage: https://github.com/ehbasouri/react-native-recaptcha-v2#readme
- Issues: https://github.com/ehbasouri/react-native-recaptcha-v2/issues
- npm.io page: https://npm.io/package/react-native-recaptcha-v2

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2020-01-07
- 1.0.1 — 2020-01-07
- 1.0.0 — 2020-01-07

## README

## react-native-recaptcha-v2
## Implement Google recaptcha v2 in React Native (both Android an iOS)


## Add it to your project

1. Insall package
- Using NPM
   `npm install react-native-recaptcha-v2` 
- Using Yarn
   `yarn add react-native-recaptcha-v2`
2. Import package
`import ConfirmGoogleCaptcha from 'react-native-recaptcha-v2';`

## Usage

### Check demo in [Snack link](https://snack.expo.io/@ehbasouri/react-native-recaptcha-v2)


```javascript
import React from 'react';
import ConfirmGoogleCaptcha from 'react-native-recaptcha-v2';
const siteKey = 'you_site_key';
const baseUrl = 'base_url';
class App extends React.Component  {
    onMessage = event => {
         if (event && event.nativeEvent.data) {
            if (['cancel', 'error', 'expired'].includes(event.nativeEvent.data)) {
                this.captchaForm.hide();
                return;
            } else {
                console.log('Verified code from Google', event.nativeEvent.data);
                setTimeout(() => {
                    this.captchaForm.hide();
                    // do what ever you want here
                }, 1500);
            }
        }
    };
    render() {
        return (
            <View style={styles.container}>
                <ConfirmGoogleCaptcha
                    ref={_ref => this.captchaForm = _ref}
                    siteKey={siteKey}
                    baseUrl={baseUrl}
                    languageCode='en'
                    onMessage={this.onMessage}
                />
                <Button
                    onPress={() => {
                        this.captchaForm.show();
                    }}
                    title='Click'
                    style={{ width: 120, backgroundColor: 'darkviolet' }}
                    textColor='#fff'
                />
            </View>
        );
    }
}
```

```
DEMO
```
![iOS](https://github.com/xuho/demo-images/blob/master/ios.gif)
![Android](https://github.com/xuho/demo-images/blob/master/android.gif)



## Props

- **`siteKey`** _(String)_ - The site key of the Google Recaptcha.
- **`baseUrl`** _(String)_ The url domain defined on your Google Recaptcha.
- **`onMessage`** _(Function)_ - The callback function  after received response, error of Google captcha or when user cancel
- **`languageCode`** _(String)_ - Language to be display of captcha form. Can be found at [this link](https://developers.google.com/recaptcha/docs/language)
- **`cancelButtonText`** _(String)_ - Title of cancel button.


**MIT Licensed**

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