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

@captcha-pro/taro-react

v2.2.0

Published

Taro + React captcha components for captcha-pro (backend-only mode)

Readme

@captcha-pro/taro-react

Taro + React captcha components for Captcha Pro (backend-only mode).

简体中文

Installation

pnpm add @captcha-pro/taro-react

Important: Backend-Only Mode

This package only supports backend verification mode. All captcha images are provided by backend API, backend configuration is required.

Usage

Slider Captcha

import { SliderCaptcha } from '@captcha-pro/taro-react'

function CaptchaPage() {
  const backendConfig = {
    getCaptcha: 'https://your-api.com/captcha/get',
    verify: 'https://your-api.com/captcha/verify',
    timeout: 10000,
  }

  const handleSuccess = () => {
    console.log('Verification passed!')
  }

  return (
    <SliderCaptcha
      backend={backendConfig}
      width={300}
      height={170}
      onSuccess={handleSuccess}
      onFail={() => console.log('Failed')}
    />
  )
}

Click Captcha

import { ClickCaptcha } from '@captcha-pro/taro-react'

function CaptchaPage() {
  return (
    <ClickCaptcha
      backend={backendConfig}
      width={300}
      height={170}
      onSuccess={() => console.log('Passed!')}
    />
  )
}

Popup Captcha

import { useRef } from 'react'
import { PopupCaptcha, type PopupCaptchaRef } from '@captcha-pro/taro-react'

function CaptchaPage() {
  const popupRef = useRef<PopupCaptchaRef>(null)

  const showPopup = () => {
    popupRef.current?.show()
  }

  return (
    <View>
      <Button onClick={showPopup}>Verify</Button>
      <PopupCaptcha
        ref={popupRef}
        type="slider"
        backend={backendConfig}
        title="请完成安全验证"
        onSuccess={() => console.log('Passed!')}
      />
    </View>
  )
}

Using Hooks

import { useSliderCaptcha } from '@captcha-pro/taro-react/hooks'

function CustomCaptcha() {
  const backendConfig = {
    getCaptcha: 'https://your-api.com/captcha/get',
    verify: 'https://your-api.com/captcha/verify',
  }

  const {
    containerRef,
    status,
    statusText,
    refresh,
    loading,
    error,
  } = useSliderCaptcha({
    backend: backendConfig,
    width: 300,
    height: 170,
    onSuccess: () => console.log('Passed!'),
  })

  return (
    <View>
      <View ref={containerRef} className="captcha-container" />
      {loading && <Text>Loading...</Text>}
      {error && <Text className="error">{error.message}</Text>}
      {status === 'success' && <Text className="success">{statusText}</Text>}
      <Button onClick={refresh}>Refresh</Button>
    </View>
  )
}

Backend Configuration (Required)

interface BackendConfig {
  getCaptcha: string | (params: any) => Promise<any>  // Required
  verify: string | (data: any) => Promise<any>        // Required
  headers?: Record<string, string>                     // Optional
  timeout?: number                                     // Optional, default: 10000
}

Example with custom functions:

import Taro from '@tarojs/taro'

const backendConfig = {
  async getCaptcha(params) {
    const res = await Taro.request({
      url: '/api/captcha/get',
      data: params,
      method: 'GET',
    })
    return res.data
  },
  async verify(data) {
    const res = await Taro.request({
      url: '/api/captcha/verify',
      data,
      method: 'POST',
    })
    return res.data
  },
}

TypeScript Support

Full TypeScript support with exported types:

import type {
  BackendConfig,
  SliderCaptchaProps,
  ClickCaptchaProps,
  PopupCaptchaProps,
  SliderCaptchaRef,
  ClickCaptchaRef,
  PopupCaptchaRef,
  UseSliderCaptchaOptions,
  UseClickCaptchaOptions,
  UseSliderCaptchaReturn,
  UseClickCaptchaReturn,
} from '@captcha-pro/taro-react'

Components

SliderCaptcha

| Prop | Type | Default | Description | |------|------|---------|-------------| | backend | BackendConfig | - | Required, backend API config | | width | number | 300 | Container width | | height | number | 170 | Container height | | sliderWidth | number | 42 | Slider piece width | | sliderHeight | number | 42 | Slider piece height | | showRefresh | boolean | true | Show refresh button | | locale | 'zh-CN' | 'en-US' | 'zh-CN' | Language | | onSuccess | () => void | - | Success callback | | onFail | () => void | - | Fail callback | | onRefresh | () => void | - | Refresh callback | | onError | (error: Error) => void | - | Error callback |

ClickCaptcha

| Prop | Type | Default | Description | |------|------|---------|-------------| | backend | BackendConfig | - | Required, backend API config | | width | number | 300 | Container width | | height | number | 170 | Container height | | showRefresh | boolean | true | Show refresh button | | locale | 'zh-CN' | 'en-US' | 'zh-CN' | Language | | onSuccess | () => void | - | Success callback | | onFail | () => void | - | Fail callback | | onError | (error: Error) => void | - | Error callback |

PopupCaptcha

| Prop | Type | Default | Description | |------|------|---------|-------------| | type | 'slider' | 'click' | 'slider' | Captcha type | | backend | BackendConfig | - | Required, backend API config | | title | string | '请完成安全验证' | Popup title | | maskClosable | boolean | true | Close on mask click | | showClose | boolean | true | Show close button | | autoClose | boolean | true | Auto close on success | | closeDelay | number | 500 | Close delay (ms) | | onSuccess | () => void | - | Success callback | | onOpen | () => void | - | Open callback | | onClose | () => void | - | Close callback |

Ref Methods

const captchaRef = useRef<SliderCaptchaRef>(null)
const popupRef = useRef<PopupCaptchaRef>(null)

// SliderCaptcha / ClickCaptcha methods
captchaRef.current?.refresh()
captchaRef.current?.getData()

// PopupCaptcha methods
popupRef.current?.show()
popupRef.current?.hide()
popupRef.current?.isVisible()

Events

| Event | Description | Payload | |-------|-------------|---------| | onSuccess | Verification passed | { verifiedAt } | | onFail | Verification failed | - | | onRefresh | Refresh clicked | - | | onError | Loading error | Error | | onOpen | Popup opened | - | | onClose | Popup closed | - |

License

MIT