nuxt-cap
nuxt-cap
๐งข Integrate Cap into your Nuxt websites/applications.
๐ Full Documentation
๐ Setup
Install nuxt-cap dependency to your project:
npx nuxt module add nuxt-cap
Or manually
-
Install with your favorite package manager:
- bun :
bun add nuxt-cap - npm :
npm i nuxt-cap - pnpm :
pnpm add nuxt-cap - yarn :
yarn add nuxt-cap
- bun :
-
Add it to your
modulessection in yournuxt.config:
export default defineNuxtConfig({
modules: ['nuxt-cap'],
cap: {
// ...configs
},
})
โ๏ธ Configuration
You can configure nuxt-cap in two ways:
1๏ธโฃ Using nuxt.config.ts
Set the apiEndpoint directly in your Nuxt configuration:
export default defineNuxtConfig({
cap: {
apiEndpoint: 'https://cap.example.com/<KEY>/',
},
})
2๏ธโฃ Using an Environment Variable (Recommended)
NUXT_PUBLIC_CAP_API_ENDPOINT="https://cap.example.com/<KEY>/"
Because this uses Nuxt runtimeConfig, it supports runtime environment variables โ meaning you can change the endpoint after build time without rebuilding your application.
๐งฉ <Cap /> Component
This module auto-imports a component called:
<Cap />
๐ก Emits
The component exposes four events:
@solve@error@reset@progress
Example
<script setup lang="ts">
function onSolve(event: CapSolveEvent): void {
console.log('Solved:', event)
}
function onError(event: CapErrorEvent): void {
console.error('Error:', event)
}
function onReset(event: CapResetEvent): void {
console.log('Reset:', event)
}
function onProgress(event: CapProgressEvent): void {
console.log('Progress:', event)
}
</script>
<template>
<Cap @solve="onSolve" @error="onError" @reset="onReset" @progress="onProgress" />
</template>
๐งฑ Props
workerCount?: number
Optional.
Defines how many Web Workers Cap should use to solve the proof-of-work challenge.
If not set, Cap defaults to:
navigator.hardwareConcurrency || 8
i18n?: object
Optional.
Allows you to customize the widget language.
{
verifyingLabel?: string
initialState?: string
solvedLabel?: string
errorLabel?: string
wasmDisabled?: string
verifyAriaLabel?: string
verifyingAriaLabel?: string
verifiedAriaLabel?: string
errorAriaLabel?: string
}
Example
<template>
<Cap
:worker-count="4"
:i18n="{
verifyingLabel: 'Verificando...',
solvedLabel: 'Verificado',
errorLabel: 'Erro',
}" />
</template>
๐จ Customizing Appearance
To customize Capโs appearance, follow the official Cap widget styling guide: Styling
๐ Reset
To reset the Cap widget programmatically, you can use the provided helper function:
resetCap()
Example
<script setup lang="ts">
function handleReset(): void {
// ...anything
resetCap()
}
</script>
<template>
<button @click="handleReset">Reset Cap</button>
<Cap />
</template>
Calling resetCap() will reset the current widget state, allowing the challenge to be solved again.
๐ช useCap composable
You can use the useCap() composable for programmatic mode.
It returns a Cap instance, similar to the one described in the official programmatic mode guide:
You can call any available Cap instance method, such as cap.solve().
Example
<script setup lang="ts">
const cap = useCap()
async function testCap(): Promise<void> {
if (!cap) return
const { token } = await cap.solve()
console.log(token)
}
</script>
<template>
<button @click="testCap">Solve Invisible Cap</button>
</template>
This allows you to manually trigger the proof-of-work challenge without rendering the <Cap /> checkbox widget.
๐ License
Copyright ยฉ 2026 Gabriel 'DethDKN' Rosa
This project is under MIT license
Related Packages
One utility function for module authors to define compiler constants for all bui...
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 1.0.3 | ^3.0 | MIT | |
| 1.0.2 | ^3.0 | MIT | |
| 1.0.1 | ^3.0 | MIT | |
| 1.0.0 | ^3.0 | MIT | |
| 0.1.2 | ^3.0 | MIT | |
| 0.1.1 | ^3.0 | MIT | |
| 0.1.0 | ^3.0 | MIT |