Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
nuxt-hcaptcha-module
Advanced tools
Changelog
Readme
🚧 Note: This project is currently under development and not yet production ready.
Nuxt module that allows to protect your website from bots. Heavily inspired by Nuxt Turnstile.
nuxt-hcaptcha-module
dependency to your project# Using pnpm
pnpm add -D nuxt-hcaptcha-module
# Using yarn
yarn add --dev nuxt-hcaptcha-module
# Using npm
npm install --save-dev nuxt-hcaptcha-module
nuxt-hcaptcha-module
to the modules
section of nuxt.config.ts
export default defineNuxtConfig({
modules: [
'nuxt-hcaptcha-module'
]
})
siteKey
and secretKey
generated in hCaptcha dashboardexport default defineNuxtConfig({
modules: ["nuxt-hcaptcha-module"],
hcaptcha: {
siteKey: 'YOUR_SITE_KEY',
secretKey: 'YOUR_SECRET_KEY'
}
});
You can also use environment variables:
HCAPTCHA_SITE_KEY=YOUR_SITE_KEY
HCAPTCHA_SECRET_KEY=YOUR_SECRET_KEY
NuxtHCaptcha
component in your application<template>
<form @submit.prevent="sendForm">
<!-- put your form fields here -->
<NuxtHCaptcha v-model="form.token" />
<button>submit</button>
</form>
</template>
<script setup>
const form = ref({
token: ''
})
async function sendForm () {
await $fetch('/api/your-api-endpoint', {
method: 'POST',
body: form.value
})
}
</script>
verifyHCaptchaToken
to validate hCaptcha token (only when you use server routes)// server/api/your-api-endpoint.ts
export default defineEventHandler(async (event) => {
const body = await readBody(event)
const captchaResponse = await verifyHCaptchaToken(body.token)
// return an error when hCaptcha detects a bot
if (!captchaResponse.success) {
return createError({
statusCode: 401
})
}
// handle logic for verified user, for example:
// await createUser({ user: body.user })
return ({ success: true })
})
# Install dependencies
npm install
# Generate type stubs
npm run dev:prepare
# Develop with the playground
npm run dev
# Build the playground
npm run dev:build
# Run ESLint
npm run lint
# Run Vitest
npm run test
npm run test:watch
# Release new version
npm run release
FAQs
Nuxt hCaptcha integration module
The npm package nuxt-hcaptcha-module receives a total of 1 weekly downloads. As such, nuxt-hcaptcha-module popularity was classified as not popular.
We found that nuxt-hcaptcha-module demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.