npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@captchala/react

v1.0.3

Published

Official Captchala CAPTCHA React component - Smart CAPTCHA protection for your React applications

Downloads

13

Readme

@captchala/react

Official Captchala CAPTCHA React component - Smart CAPTCHA protection for your React applications.

npm version npm downloads license

Installation

npm install @captchala/react
# or
yarn add @captchala/react
# or
pnpm add @captchala/react

Quick Start

Component Approach

import { Captchala } from '@captchala/react'

function App() {
  const handleSuccess = (result) => {
    console.log('Verification successful!')
    console.log('Token:', result.token)
    // Send token to your server for validation
  }

  return (
    <Captchala
      appKey="your-app-key"
      product="popup"
      onSuccess={handleSuccess}
      onError={(err) => console.error(err)}
    />
  )
}

Hook Approach

import { useCaptchala } from '@captchala/react'

function LoginForm() {
  const { ready, verify } = useCaptchala({
    appKey: 'your-app-key',
    product: 'bind',
    action: 'login'
  })

  const handleSubmit = async (e) => {
    e.preventDefault()

    try {
      const result = await verify()
      console.log('Token:', result.token)
      // Continue with form submission
    } catch (err) {
      console.error('Verification failed:', err)
    }
  }

  return (
    <form onSubmit={handleSubmit}>
      <input type="email" placeholder="Email" />
      <input type="password" placeholder="Password" />
      <button type="submit" disabled={!ready}>
        Login
      </button>
    </form>
  )
}

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | appKey | string | required | Your Captchala application key | | product | 'popup' \| 'float' \| 'embed' \| 'bind' | 'popup' | Display mode | | action | string | 'default' | Action identifier (e.g., 'login', 'register', 'checkout') | | lang | string | 'zh-CN' | Language code ('zh-CN', 'en', 'ja', etc.) | | onSuccess | (result) => void | - | Success callback | | onError | (error) => void | - | Error callback | | onClose | () => void | - | Close callback | | onReady | () => void | - | Ready callback | | className | string | - | Container class name | | style | CSSProperties | - | Container inline styles |

Methods (via ref)

import { useRef } from 'react'
import { Captchala, CaptchalaRef } from '@captchala/react'

function App() {
  const captchaRef = useRef<CaptchalaRef>(null)

  const handleManualVerify = () => {
    captchaRef.current?.verify()
  }

  return (
    <>
      <Captchala ref={captchaRef} appKey="your-key" />
      <button onClick={handleManualVerify}>Verify</button>
    </>
  )
}

| Method | Description | |--------|-------------| | verify() | Trigger verification | | reset() | Reset CAPTCHA state | | destroy() | Destroy CAPTCHA instance | | bindTo(selector) | Bind to element (for 'bind' mode) |

useCaptchala Hook

const {
  ready,      // boolean - SDK is loaded and ready
  loading,    // boolean - SDK is loading
  error,      // Error | null - Loading error
  verify,     // () => Promise<CaptchalaResult> - Trigger verification
  reset,      // () => void - Reset state
  bindTo,     // (selector) => void - Bind to element
  appendTo    // (selector) => void - Append to element
} = useCaptchala(options)

Display Modes

Popup Mode (Default)

Shows a button that triggers a popup CAPTCHA dialog.

<Captchala appKey="your-key" product="popup" />

Float Mode

Displays an inline floating CAPTCHA widget.

<Captchala appKey="your-key" product="float" />

Embed Mode

Embeds the CAPTCHA directly in the page.

<Captchala appKey="your-key" product="embed" />

Bind Mode with Hook

Best for form submissions - verifies when the user submits.

function Form() {
  const { ready, verify } = useCaptchala({
    appKey: 'your-key',
    product: 'bind'
  })

  const handleSubmit = async () => {
    const result = await verify()
    // result.token contains the verification token
  }

  return <button onClick={handleSubmit} disabled={!ready}>Submit</button>
}

Server-side Validation

After receiving the token from onSuccess, validate it on your server:

// Your backend
const response = await fetch('https://api.captcha.la/v1/risk/consume', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-App-Key': 'your-app-key',
    'X-App-Secret': 'your-app-secret'
  },
  body: JSON.stringify({ token })
})

const result = await response.json()
if (result.code === 0 && result.data.valid) {
  // Token is valid, proceed with the request
}

TypeScript Support

Full TypeScript support is included:

import {
  Captchala,
  useCaptchala,
  type CaptchalaProps,
  type CaptchalaResult,
  type CaptchalaRef,
  type UseCaptchalaOptions
} from '@captchala/react'

License

MIT License - see LICENSE for details.

Links