All Projects → appleboy → React Recaptcha

appleboy / React Recaptcha

Licence: bsd-3-clause
A react.js reCAPTCHA for Google

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Recaptcha

ContactEtc
Laraval package to instantly add a customisable contact form to your site.
Stars: ✭ 21 (-96.39%)
Mutual labels:  recaptcha
LSTM-CTC-recaptcha
recaptcha with lstm and mxnet
Stars: ✭ 28 (-95.19%)
Mutual labels:  recaptcha
Nocaptcha
🛂 Helper for Google's new noCAPTCHA (reCAPTCHA v2 & v3)
Stars: ✭ 313 (-46.22%)
Mutual labels:  recaptcha
vue-programmatic-invisible-google-recaptcha
🔒A simple invisible Google reCAPTCHA component focused solely on programmatic invocation.
Stars: ✭ 28 (-95.19%)
Mutual labels:  recaptcha
recaptcha
An easy-to-use reCAPTCHA package
Stars: ✭ 55 (-90.55%)
Mutual labels:  recaptcha
recaptcha-2-phpbbmod
reCAPTCHA v2 for phpBB Olympus 3.0
Stars: ✭ 14 (-97.59%)
Mutual labels:  recaptcha
Codeigniter-recaptcha
CodeIgniter library to use Google's reCAPTCHA V2
Stars: ✭ 25 (-95.7%)
Mutual labels:  recaptcha
Vue Crud X
Vue+Express Cookbook & CRUD Component (with Vite and Web Components)
Stars: ✭ 393 (-32.47%)
Mutual labels:  recaptcha
AspNetCore-ReCAPTCHAv3
reCAPTCHA v3 Usage in Asp.Net Core MVC
Stars: ✭ 17 (-97.08%)
Mutual labels:  recaptcha
Recaptcha
PHP client library for reCAPTCHA, a free service to protect your website from spam and abuse.
Stars: ✭ 3,149 (+441.07%)
Mutual labels:  recaptcha
2captcha-python
Python 3 package for easy integration with the API of 2captcha captcha solving service to bypass recaptcha, hcaptcha, funcaptcha, geetest and solve any other captchas.
Stars: ✭ 140 (-75.95%)
Mutual labels:  recaptcha
2captcha-php
PHP package for easy integration with the API of 2captcha captcha solving service to bypass recaptcha, hcaptcha, funcaptcha, geetest and solve any other captchas.
Stars: ✭ 25 (-95.7%)
Mutual labels:  recaptcha
Anspress
AnsPress is the most complete question and answer system for WordPress. AnsPress is made with developers in mind, highly customizable. AnsPress provide an easy to use override system for theme
Stars: ✭ 264 (-54.64%)
Mutual labels:  recaptcha
wagtail-django-recaptcha
A simple recaptcha field for Wagtail Form Pages
Stars: ✭ 47 (-91.92%)
Mutual labels:  recaptcha
Reaptcha
Google reCAPTCHA v2 for React
Stars: ✭ 329 (-43.47%)
Mutual labels:  recaptcha
Contact-Form-PHP
Simple and secure contact form using Ajax, validations inputs, SMTP protocol and Google reCAPTCHA v3 in PHP.
Stars: ✭ 28 (-95.19%)
Mutual labels:  recaptcha
react-google-invisible-recaptcha
A React component which is simply interested in Google invisible reCaptcha.
Stars: ✭ 58 (-90.03%)
Mutual labels:  recaptcha
Angular Recaptcha
AngularJS directive to add a reCaptcha widget to your form
Stars: ✭ 502 (-13.75%)
Mutual labels:  recaptcha
Buster
Captcha solver extension for humans
Stars: ✭ 4,244 (+629.21%)
Mutual labels:  recaptcha
Laravel Recaptcha
Google ReCaptcha package for Laravel
Stars: ✭ 273 (-53.09%)
Mutual labels:  recaptcha

react-recaptcha

NPM version Downloads Build Status devDependency Status

NPM

A react.js reCAPTCHA V2 for Google. The FREE anti-abuse service. Easy to add, advanced security, accessible to wide range of users and platforms.

What is reCAPTCHA?

reCAPTCHA is a free service that protects your site from spam and abuse. It uses advanced risk analysis engine to tell humans and bots apart. With the new API, a significant number of your valid human users will pass the reCAPTCHA challenge without having to solve a CAPTCHA (See blog for more details). reCAPTCHA comes in the form of a widget that you can easily add to your blog, forum, registration form, etc.

See the details.

Sign up for an API key pair

To use reCAPTCHA, you need to sign up for an API key pair for your site. The key pair consists of a site key and secret. The site key is used to display the widget on your site. The secret authorizes communication between your application backend and the reCAPTCHA server to verify the user's response. The secret needs to be kept safe for security purposes.

Installation

Install package via node.js

$ npm install --save react-recaptcha

Usage

You can see the full example by following steps.

$ npm install
$ npm start

open the http://localhost:3000 in your browser.

Node support

Node >= v6 is required for this package. Run node -v in your command prompt if you're unsure which Node version you have installed.

Automatically render the reCAPTCHA widget

Html example code:

<html>
  <head>
    <title>reCAPTCHA demo: Simple page</title>
    <script src="build/react.js"></script>
    <script src="https://www.google.com/recaptcha/api.js" async defer></script>
  </head>
  <body>
    <div id="example"></div>
    <script src="build/index.js"></script>
  </body>
</html>

Jsx example code: build/index.js

var Recaptcha = require('react-recaptcha');

ReactDOM.render(
  <Recaptcha
    sitekey="xxxxxxxxxxxxxxxxxxxx"
  />,
  document.getElementById('example')
);

Explicitly render the reCAPTCHA widget

Deferring the render can be achieved by specifying your onload callback function and adding parameters to the JavaScript resource.

<html>
  <head>
    <title>reCAPTCHA demo: Simple page</title>
    <script src="build/react.js"></script>
    <script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer></script>
  </head>
  <body>
    <div id="example"></div>
    <script src="build/index.js"></script>
  </body>
</html>

Jsx example code: build/index.js

var Recaptcha = require('react-recaptcha');

// specifying your onload callback function
var callback = function () {
  console.log('Done!!!!');
};

ReactDOM.render(
  <Recaptcha
    sitekey="xxxxxxxxxxxxxxxxxxxx"
    render="explicit"
    onloadCallback={callback}
  />,
  document.getElementById('example')
);

Define verify Callback function

var Recaptcha = require('react-recaptcha');

// specifying your onload callback function
var callback = function () {
  console.log('Done!!!!');
};

// specifying verify callback function
var verifyCallback = function (response) {
  console.log(response);
};

ReactDOM.render(
  <Recaptcha
    sitekey="xxxxxxxxxxxxxxxxxxxx"
    render="explicit"
    verifyCallback={verifyCallback}
    onloadCallback={callback}
  />,
  document.getElementById('example')
);

Change the color theme of the widget. Place theme property light|dark. Default value is light.

ReactDOM.render(
  <Recaptcha
    sitekey="xxxxxxxxxxxxxxxxxxxx"
    theme="dark"
  />,
  document.getElementById('example')
);

Change the type of CAPTCHA to serve. Please type property audio|image. Default value is image.

ReactDOM.render(
  <Recaptcha
    sitekey="xxxxxxxxxxxxxxxxxxxx"
    type="audio"
  />,
  document.getElementById('example')
);

Explicitly reset the reCAPTCHA widget

The reCAPTCHA widget can be manually reset by accessing the component instance via a callback ref and calling .reset() on the instance.

var Recaptcha = require('react-recaptcha');

// create a variable to store the component instance
let recaptchaInstance;

// create a reset function
const resetRecaptcha = () => {
  recaptchaInstance.reset();
};

ReactDOM.render(
  <div>
    <Recaptcha
      ref={e => recaptchaInstance = e}
      sitekey="xxxxxxxxxxxxxxxxxxxx"
    />
    <button
      onClick={resetRecaptcha}
    >
     Reset
    </button>
  </div>,
  document.getElementById('example')
);

Component props

Available props

The following props can be passed into the React reCAPTCHA component. These can also be viewed in the source code

  • className : the class for the reCAPTCHA div.
  • onloadCallbackName : the name of your onloadCallback function (see onloadCallback below).
  • elementID : the #id for the reCAPTCHA div.
  • onloadCallback : the callback to pass into the reCAPTCHA API if rendering the reCAPTCHA explicitly.
  • verifyCallback : the callback that fires after reCAPTCHA has verified a user.
  • expiredCallback : optional. A callback to pass into the reCAPTCHA if the reCAPTCHA response has expired.
  • render : specifies the render type for the component (e.g. explicit), see onloadCallback and explicit rendering.
  • sitekey : the sitekey for the reCAPTCHA widget, obtained after signing up for an API key.
  • theme : the color theme for the widget, either light or dark.
  • type : the type of reCAPTCHA you'd like to render, list of reCAPTCHA types available here.
  • verifyCallbackName : the name of your verifyCallback function, see verifyCallback above.
  • expiredCallbackName : the name of your expiredCallbackName function, see expiredCallback above.
  • size : the desired size of the reCAPTCHA widget, can be either 'compact' or 'normal'.
  • tabindex : optional: The tabindex of the widget and challenge. If other elements in your page use tabindex, it should be set to make user navigation easier. More info on tabindex available here.
  • hl : optional. Forces the widget to render in a specific language. Auto-detects the user's language if unspecified. List of language codes available here.
  • badge : optional. Reposition the reCAPTCHA badge. 'inline' allows you to control the CSS.

Default props

If not specified when rendering the component, the following props will be passed into the reCAPTCHA widget:

  {
    elementID: 'g-recaptcha',
    onloadCallback: undefined,
    onloadCallbackName: 'onloadCallback',
    verifyCallback: undefined,
    verifyCallbackName: 'verifyCallback',
    expiredCallback: undefined,
    expiredCallbackName: 'expiredCallback',
    render: 'onload',
    theme: 'light',
    type: 'image',
    size: 'normal',
    tabindex: '0',
    hl: 'en',
    badge: 'bottomright',
  };

Using invisible reCAPTCHA

Use the invisible reCAPTCHA by setting size prop to 'invisible'. Since it is invisible, the reCAPTCHA widget must be executed programatically.

var Recaptcha = require('react-recaptcha');

// create a variable to store the component instance
let recaptchaInstance;

// manually trigger reCAPTCHA execution
const executeCaptcha = function () {
  recaptchaInstance.execute();
};

// executed once the captcha has been verified
// can be used to post forms, redirect, etc.
const verifyCallback = function (response) {
  console.log(response);
  document.getElementById("someForm").submit();
};

ReactDOM.render(
  <div>
    <form id="someForm" action="/search" method="get">
      <input type="text" name="query">
    </form>
    <button
      onClick={executeCaptcha}
    >
     Submit
    </button>

    <Recaptcha
      ref={e => recaptchaInstance = e}
      sitekey="xxxxxxxxxxxxxxxxxxxx"
      size="invisible"
      verifyCallback={verifyCallback}
    />
  </div>,
  document.getElementById('example')
);

Contributing

    1. Fork it
    1. Create your feature branch (git checkout -b my-new-feature)
    1. Commit your changes (git commit -am 'Add some feature')
    1. Push to the branch (git push origin my-new-feature)
    1. Create new Pull Request
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].