1.1.0 • Published 1 year ago

@nerimity/solid-turnstile v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

solid-turnstile

pnpm

SolidJS library for Cloudflare Turnstile.

Inspired by https://github.com/Le0developer/react-turnstile

Quick start

Install it:

npm i solid-turnstile
# or
yarn add solid-turnstile
# or
pnpm add solid-turnstile

Use it:

import {Turnstile} from "solid-turnstile";

function TurnstileWidget() {
  let ref: TurnstileRef | undefined;

  createEffect(() => {
    ref?.reset() // resets the captcha whenever you need to.
  })

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

Arguments

NameTypeDescription
sitekeystringsitekey of your website
theme?stringone of "light", "dark", "auto"
retry?stringone of "auto", "never"
autoResetOnExpire?booleanautomatically reset the widget when the token expires

Callbacks

NameArgumentsDescription
onVerifytokencalled when challenge is passed
onLoad?widgetIdcalled when the widget is loaded
onError?errorcalled when an error occurs
onExpire?-called when the token expires
onTimeout?-called when the challenge expires