verify-hcaptcha
Version:
A fully typed library to verify hCaptcha.com tokens submitted by users when solving captcha challenges
78 lines (54 loc) • 2.06 kB
Markdown
# ✅ verify-hcaptcha
[](https://github.com/velut/verify-hcaptcha/actions?query=workflow%3ACI)
[](https://codecov.io/gh/velut/verify-hcaptcha)
[](https://www.jsdocs.io/package/verify-hcaptcha)

[](https://www.npmjs.com/package/verify-hcaptcha)
[](https://github.com/velut/verify-hcaptcha/blob/main/LICENSE)
A fully typed library to verify hCaptcha.com tokens submitted by users when solving captcha challenges.
> [!WARNING]
> This is an **unofficial** library; we are not affiliated with hCaptcha.com.
## Useful resources
- [**Explore the API on jsDocs.io**](https://www.jsdocs.io/package/verify-hcaptcha)
- View package contents on [**unpkg**](https://unpkg.com/verify-hcaptcha/)
- View repository on [**GitHub**](https://github.com/velut/verify-hcaptcha)
- Read the changelog on [**GitHub**](https://github.com/velut/verify-hcaptcha/blob/main/CHANGELOG.md)
- Read the official documentation on [**hCaptcha**](https://docs.hcaptcha.com/)
## Install
Using `npm`:
```
npm add verify-hcaptcha
```
Using `yarn`:
```
yarn add verify-hcaptcha
```
Using `pnpm`:
```
pnpm add verify-hcaptcha
```
Using `bun`:
```
bun add verify-hcaptcha
```
## Usage Examples
Verify a token submitted by a user:
```typescript
import { verifyHcaptchaToken } from "verify-hcaptcha";
const result = await verifyHcaptchaToken({
token: "USER-SUBMITTED-RESPONSE-TOKEN",
secretKey: "YOUR-SECRET-KEY",
siteKey: "YOUR-SITE-KEY",
});
if (result.success) {
console.log("User is human");
} else {
console.log("User is robot");
}
```
## License
```
MIT
```
Copyright (c) 2025 Edoardo Scibona
See [LICENSE](./LICENSE) file.