Socket
Socket
Sign inDemoInstall

react-turnstile

Package Overview
Dependencies
5
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-turnstile

React library for Cloudflare's Turnstile CAPTCHA alternative


Version published
Maintainers
1
Install size
23.6 kB
Created

Changelog

Source

[1.1.0] - 2023-03-09

Added

  • refreshExpired option
  • language option
  • appearance option
  • execution option

Changed

  • Temporary load callback function is now removed after load

Fixed

  • onTimeout callback not properly registering
  • ref not passing properly - pass userRef instead
  • globalThis errors on older browsers

Removed

  • autoResetOnExpire - use refreshExpired instead

Readme

Source

react-turnstile

A very simple React library for Cloudflare Turnstile.

Installation

npm i react-turnstile

Usage

import Turnstile from "react-turnstile";

// ...

function TurnstileWidget() {
  return (
    <Turnstile
      sitekey="1x00000000000000000000AA"
      onVerify={(token) => alert(token)}
    />
  );
}

Turnstile tokens expire after 5 minutes, to automatically reset the challenge once they expire, set the autoResetOnExpire prop to true or reset the widget yourself using the onExpire callback.

Documentation

Turnstile takes the following arguments:

nametypedescription
sitekeystringsitekey of your website (REQUIRED)
actionstring-
cDatastring-
themestringone of "light", "dark", "auto"
tabIndexnumber-
responseFieldbooleancontrols generation of <input /> element
responseFieldNamestringchanges the name of <input /> element
retrystringone of "auto", "never"
retryIntervalnumberinterval of retries in ms
autoResetOnExpirebooleanautomatically reset the widget when the token expires
idstringid of the div
refRefcustom react ref for the div
classNamestringpassed to the div
styleobjectpassed to the div

And the following callbacks:

nameargumentsdescription
onVerifytokencalled when challenge is passed (REQUIRED)
onLoadwidgetIdcalled when the widget is loaded
onErrorerrorcalled when an error occurs
onExpire-called when the token expires
onTimeout-called when the challenge expires

For more details on what each argument does, see the Cloudflare Documentation.

FAQs

Last updated on 09 Mar 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc