New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-recaptcha-that-works

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-recaptcha-that-works

⚛ A reCAPTCHA bridge for React Native that works.

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.5K
decreased by-52.41%
Maintainers
1
Weekly downloads
 
Created
Source

reCAPTCHA for React Native (Android and iOS)

License MIT npm version npm downloads

A reCAPTCHA library for React Native (Android and iOS) that works.

Looking for React DOM version?

NormalInvisible

Try the Online demo.

Install

Install the module

  yarn add react-native-recaptcha-that-works react-native-webview

Or

  npm i -S react-native-recaptcha-that-works react-native-webview

See the react-native-webview Getting Started Guide.

Usage

With JavaScript:

import React, { useRef } from 'react';
import { View, Button } from 'react-native';

import Recaptcha from 'react-native-recaptcha-that-works';

const App = () => {
    const recaptcha = useRef();

    const send = () => {
        console.log('send!');
        this.recaptcha.current.open();
    }

    const onVerify = token => {
        console.log('success!', token);
    }

    const onExpire = () => {
        console.warn('expired!');
    }

    return (
        <View>
            <Recaptcha
                ref={recaptcha}
                siteKey="<your-recaptcha-public-key>"
                baseUrl="http://my.domain.com"
                onVerify={onVerify}
                onExpire={onExpire}
                size="invisible"
            />
            <Button title="Send" onPress={send} />
        </View>
    );
}
Or with TypeScript:
import React, { useRef } from 'react';
import { View, Button } from 'react-native';

import Recaptcha, { RecaptchaHandles } from "react-native-recaptcha-that-works";

// ...

export const Component: React.FC = () => {
    const recaptcha = useRef<RecaptchaHandles>(null);

    const send = () => {
        console.log('send!');
        recaptcha.current?.open();
    };

    const onVerify = (token: string) => {
        console.log('success!', token);
    };

    const onExpire = () => {
        console.warn('expired!');
    }

    return (
        <View>
            <Recaptcha
                ref={recaptcha}
                siteKey="<your-recaptcha-public-key>"
                baseUrl="http://my.domain.com"
                onVerify={onVerify}
                onExpire={onExpire}
                size="invisible"
            />
            <Button title="Send" onPress={send} />
        </View>
    );
};

For more details, see the Sample Project.

Props

NameValueDefaultDescription
headerComponentReact ElementA component to render on top of Modal.
footerComponentReact ElementA component to render on bottom of Modal.
loadingComponentReact ElementA custom loading component.
styleViewStyleCustomize default style such as background color.
modalPropsModalPropsOverride the Modal props.
webViewPropsWebViewPropsOverride the WebView props.
langstringLanguage code.
siteKeystring(Required) Your Web reCAPTCHA site key. (The Web key must be used, not for Android)
baseUrlstring(Required) The URL (domain) configured in the reCAPTCHA console setup. (ex. http://my.domain.com) (See also https://github.com/douglasjunior/react-native-recaptcha-that-works/issues/34)
size'invisible', 'normal' or 'compact''normal'The size of the widget.
theme'dark' or 'light''light'The color theme of the widget.
onLoadfunction()A callback function, executed when the reCAPTCHA is ready to use.
onVerifyfunction(token)(Required) A callback function, executed when the user submits a successful response. The reCAPTCHA response token is passed to your callback.
onExpirefunction()A callback function, executed when the reCAPTCHA response expires and the user needs to re-verify. Only works if the webview still open after onVerify has been called for a long time.
onErrorfunction(error)A callback function, executed when reCAPTCHA encounters an error (usually network connectivity) and cannot continue until connectivity is restored. If you specify a function here, you are responsible for informing the user that they should retry.
onClosefunction()A callback function, executed when the Modal is closed.
recaptchaDomainstringwww.google.comThe host name of the reCAPTCHA valid api. See detail.
gstaticDomainstringwww.gstatic.comCustomize reCAPTCHA gstatic host.
hideBadgebooleanfalseWhen size = 'invisible', you are allowed to hide the badge as long as you include the reCAPTCHA branding visibly in the user flow. See detail.
enterpriseboolean (enterprise)falseUse the new reCAPTCHA Enterprise API.
actionstring (enterprise)An additional parameter for specifying the action name associated with the protected element for reCAPTCHA Enterprise API.

Note: If lang is not set, then device language is used.

Methods

NameTypeDescription
openfunctionOpen the reCAPTCHA Modal.
closefunctionClose the reCAPTCHA Modal.

Note: If using size="invisible", then challenge run automatically when open is called.

reCAPTCHA v2 docs

reCAPTCHA Enterprise docs

Contribute

New features, bug fixes and improvements are welcome! For questions and suggestions, use the issues.

Become a Patron! Donate

License

The MIT License (MIT)

Copyright (c) 2020 Douglas Nassif Roma Junior

See the full license file.

Keywords

FAQs

Package last updated on 19 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc