Skip to content

React

@cluion/turing-react wraps the <turing-captcha> Web Component as a React component with callback props. Portable across React 18 and 19.

Install

bash
pnpm add @cluion/turing-react

react is a peer dependency (^18 || ^19); it is never bundled.

Use

tsx
import { Turing } from '@cluion/turing-react';

export function SignupForm() {
  return (
    <form method="post" action="/submit">
      <Turing
        url="/turing/challenge"
        type="pow"
        onSolved={() => {/* enable submit, etc. */}}
        onError={(error) => console.error(error)}
      />
      <button type="submit">Send</button>
    </form>
  );
}

Props

PropRequiredDescription
urlyesChallenge endpoint URL.
typenoChallenge type, e.g. pow.
fieldnoHidden input name (default turing_token).
onSolvednoCalled once the token is injected.
onErrornoCalled with the error on failure.

The component renders in light DOM so the injected hidden input stays inside your <form> and submits normally. Events are wired via a ref effect (with cleanup), so callbacks stay current across re-renders.