Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@captchafox/react

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

@captchafox/react

[![NPM version](https://img.shields.io/npm/v/@captchafox/react.svg)](https://www.npmjs.com/package/@captchafox/react)

  • 1.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
435
decreased by-61.02%
Maintainers
1
Weekly downloads
 
Created
Source

@captchafox/react

NPM version

Installation

Install the library using your prefered package manager

npm install @captchafox/react
yarn add @captchafox/react
pnpm add @captchafox/react
bun add @captchafox/react

Usage

import { CaptchaFox } from '@captchafox/react';

function Example() {
  return <CaptchaFox sitekey="sk_11111111000000001111111100000000" />;
}

Props

PropTypeDescriptionRequired
sitekeystringThe sitekey for the widget
langstringThe language the widget should display. Defaults to automatically detecting it.
modeinline|popup|hiddenThe mode the widget should be displayed in .
themelight | dark | ThemeDefinitionThe theme of the widget. Defaults to light.
onVerifyfunctionCalled with the response token after successful verification.
onFailfunctionCalled after unsuccessful verification.
onErrorfunctionCalled when an error occured.
onExpirefunctionCalled when the challenge expires.
onClosefunctionCalled when the challenge was closed.

Using the verification callback

import { CaptchaFox, CAPTCHA_RESPONSE_KEY } from '@captchafox/react';

function Example() {
  const handleVerify = (token: string) => {
    // do something with the token here (e.g. submit the form)
    const formData = {
      // your form data
      [CAPTCHA_RESPONSE_KEY]: token
    };
  };

  return <CaptchaFox sitekey="sk_11111111000000001111111100000000" onVerify={handleVerify} />;
}

Interacting with the instance

import { useRef } from 'react'
import { CaptchaFox, CaptchaFoxInstance } from '@captchafox/react'

function Example() {
    const captchaRef = useRef<CaptchaFoxInstance | null>(null);

    const triggerAction = async () => {
        // execute the captcha
        try {
            const token = await captchaRef.current?.execute()
        } catch {
            // unsuccessful verification
        }
    }

    return (
        <CaptchaFox
            sitekey="sk_11111111000000001111111100000000"
            ref={captchaRef}
        />
        <button onClick={triggerAction}>Action</button>
    )
}

You can find more detailed examples in the GitHub repository.

FAQs

Package last updated on 09 Jan 2024

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