Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nerimity/solid-turnstile
Cloudflare Turnstile for SolidJS
https://github.com/nerimity/solid-turnstile
cloudflare solidjs turnstile
Last synced: 14 days ago
JSON representation
Cloudflare Turnstile for SolidJS
- Host: GitHub
- URL: https://github.com/nerimity/solid-turnstile
- Owner: Nerimity
- License: mit
- Created: 2023-01-05T10:06:09.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-05T16:02:02.000Z (about 2 years ago)
- Last Synced: 2025-01-23T16:17:17.199Z (14 days ago)
- Topics: cloudflare, solidjs, turnstile
- Language: TypeScript
- Homepage:
- Size: 32.2 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
# solid-turnstile
[![pnpm](https://img.shields.io/badge/maintained%20with-pnpm-cc00ff.svg?style=for-the-badge&logo=pnpm)](https://pnpm.io/)
SolidJS library for Cloudflare Turnstile.
Inspired by https://github.com/Le0developer/react-turnstile
## Quick start
Install it:
```bash
npm i solid-turnstile
# or
yarn add solid-turnstile
# or
pnpm add solid-turnstile
```Use it:
```tsx
import {Turnstile} from "solid-turnstile";function TurnstileWidget() {
let ref: TurnstileRef | undefined;createEffect(() => {
ref?.reset() // resets the captcha whenever you need to.
})return (
alert(token)}
/>
);
}
```Arguments
| Name | Type | Description |
| ----------------- | ------- | ----------------------------------------------------- |
| sitekey | string | sitekey of your website |
| theme? | string | one of "light", "dark", "auto" |
| retry? | string | one of "auto", "never" |
| autoResetOnExpire? | boolean | automatically reset the widget when the token expires |Callbacks
| Name | Arguments | Description |
| --------- | --------- | ------------------------------------------ |
| onVerify | token | called when challenge is passed |
| onLoad? | widgetId | called when the widget is loaded |
| onError? | error | called when an error occurs |
| onExpire? | - | called when the token expires |
| onTimeout? | - | called when the challenge expires |