@private-captcha/private-captcha-vue

Vue component for the client-side Private Captcha widget
568 1
Install
npm install @private-captcha/private-captcha-vue
Latest Version:0.0.5
Vue:3
License:MIT
Last Updated:Oct 23, 2026
Links: GitHub  ·  npm
Maintainer: ribtoks

Private Captcha Vue Component

A typed Vue 3 component for Private Captcha's client-side proof-of-work widget.

Installation

npm install @private-captcha/private-captcha-vue

Usage

The component must be rendered inside a form.

<script setup lang="ts">
import { ref } from 'vue';
import {
  PrivateCaptcha,
  type PrivateCaptchaEventDetail,
  type PrivateCaptchaExposed,
} from '@private-captcha/private-captcha-vue';

const captcha = ref<PrivateCaptchaExposed | null>(null);

function handleFinish(detail: PrivateCaptchaEventDetail): void {
  console.log('Captcha solved', detail.widget.solution());
}
</script>

<template>
  <form>
    <PrivateCaptcha
      ref="captcha"
      site-key="your-site-key"
      @finish="handleFinish"
    />
    <button type="button" @click="captcha?.reset()">Reset</button>
  </form>
</template>

The hidden solution field is added to the parent form by the widget and must be verified on your server.

Props

Prop Type Default
siteKey string Required
startMode 'auto' | 'click' | 'load'` 'auto'
debug boolean false
fieldName string 'private-captcha-solution'
puzzleEndpoint string Private Captcha endpoint
displayMode 'widget' | 'popup' | 'hidden' 'widget'
lang Supported language code or 'auto' 'auto'
theme 'light' | 'dark' 'light'
styles string Widget defaults
storeVariable string None
eu boolean false
compat 'recaptcha' None

See the widget options documentation for option details.

All props except storeVariable are reactive and reset the widget with the current configuration. To change storeVariable, remount the component with a new Vue key.

Events

The component emits init, start, finish, error, and reset. Each event receives a PrivateCaptchaEventDetail containing the host element and the public widget facade.

Public Methods

A component template ref exposes:

  • execute(): void
  • reset(): void
  • solution(): string | null
  • element(): HTMLElement

Completion is reported through the finish event; execute() is intentionally not awaitable.

SSR and Cleanup

The package can be imported and server-rendered without browser globals. The core widget is created only after client mount.

The upstream core currently has no complete destroy API. This component removes its own listeners and resets the widget before unmount, but the core may retain its form focus listener when only the component is removed. Prefer keeping one widget mounted or unmounting its containing form at the same time.

Requirements

  • Vue 3.3 or later

License

MIT

Related Packages

vue-slider-captcha

使用方法

739
kncaptcha

Privacy-friendly proof-of-work captcha: memory-hard Equihash puzzles solved in t...

192
@johnnyguan/vue-captcha-code

vue captcha code

2,470 0
vue-recaptcha-eh

Using recaptcha in Vue app

1,053 0

Version History

Version Released Vue License
0.0.5 ^3.3.0 MIT
0.0.4 ^3.3.0 MIT
0.0.3 ^3.3.0 MIT
0.0.1 ^3.3.0 MIT