Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/edde746/svelte-captcha-enhance

Easily add captchas to SvelteKit forms
https://github.com/edde746/svelte-captcha-enhance

captcha forms hcaptcha recaptcha sveltekit turnstile

Last synced: 3 months ago
JSON representation

Easily add captchas to SvelteKit forms

Awesome Lists containing this project

README

        

# svelte-captcha-enhance

A lightweight SvelteKit utility to easily add a captcha to your forms with progressive enhancement. Currently reCaptcha, hCaptcha and turnstile are supported.

## Installation

Use npm to install the `svelte-captcha-enhance` package:

```bash
npm install svelte-captcha-enhance
```

## Example

Below is an example of how to use `svelte-captcha-enhance` in your SvelteKit application:

```svelte

import { env } from '$env/dynamic/public';
import enhance from 'svelte-captcha-enhance';

({ result }) => {
alert(result.data.message);
}
}}
>

Submit

```

Check [src/routes](https://github.com/edde746/svelte-captcha-enhance/tree/master/src/routes) for full examples of hCaptcha & Turnstile.

## Usage

You'll need to get your `sitekey` from the desired captcha provider and include it in your environment variables (`PUBLIC_SITEKEY` in the example).

The `callback` function is the same as what would usually be passed to the `enhance` function ([documentation](https://kit.svelte.dev/docs/form-actions#progressive-enhancement)).