Crovly

Vue SDK

Use Crovly captcha in Vue 3 applications.

Installation

npm install @crovly/vue

Basic Usage

<script setup lang="ts">
import { ref } from 'vue';
import { CrovlyCaptcha } from '@crovly/vue';

const token = ref<string | null>(null);

function handleVerify(t: string) {
  token.value = t;
}

async function handleSubmit() {
  const res = await fetch('/api/submit', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ token: token.value }),
  });
}
</script>

<template>
  <form @submit.prevent="handleSubmit">
    <CrovlyCaptcha
      site-key="YOUR_SITE_KEY"
      @verify="handleVerify"
    />
    <button type="submit" :disabled="!token">Submit</button>
  </form>
</template>

Props

PropTypeDefaultDescription
siteKeystringYour public site key (required)
apiUrlstringhttps://api.crovly.comAPI endpoint
theme'light' | 'dark' | 'auto''auto'Widget theme
size'normal' | 'managed' | 'invisible''normal'Widget mode
langstringBrowser defaultLanguage code
badgebooleantrueShow "Protected by Crovly" badge
primaryColorstringCustom accent color (hex, e.g. #6366f1)
responseFieldNamestring'crovly-token'Hidden input field name

Events

EventPayloadDescription
verifystringEmitted on successful verification with the token
error{ code: string, message: string }Emitted on error
expireEmitted when the token expires

useCrovly Composable

For programmatic control:

<script setup lang="ts">
import { CrovlyCaptcha, useCrovly } from '@crovly/vue';

const { reset, getResponse } = useCrovly();

async function handleSubmit() {
  const token = getResponse();
  if (!token) return;

  const res = await fetch('/api/submit', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ token }),
  });

  if (!res.ok) {
    reset(); // re-run verification
  }
}
</script>

<template>
  <form @submit.prevent="handleSubmit">
    <CrovlyCaptcha site-key="YOUR_SITE_KEY" />
    <button type="submit">Submit</button>
  </form>
</template>

Composable Methods

MethodReturnsDescription
reset()voidReset the widget and re-run verification
getResponse()string | nullGet the current token
remove()voidRemove the widget and clean up

Nuxt 3

The widget uses browser APIs, so wrap it in <ClientOnly>:

<template>
  <ClientOnly>
    <CrovlyCaptcha
      site-key="YOUR_SITE_KEY"
      @verify="handleVerify"
    />
  </ClientOnly>
</template>

TypeScript

Full type definitions are included:

import type { CrovlyCaptchaProps } from '@crovly/vue';

On this page