Vue reCAPTCHA-v3 is a library designed to simplify the integration of Google reCAPTCHA v3 into Vue.js applications. It leverages the underlying `recaptcha-v3` package to provide an easy-to-use API for executing reCAPTCHA actions and obtaining tokens. The current stable version, 2.0.1, fully supports Vue 3, with previous versions (specifically ^1.9.0) available for Vue 2 applications. The package has a moderate release cadence, with updates typically coinciding with feature additions, bug fixes, or updates to the core `recaptcha-v3` dependency. Its key differentiator is its straightforward API for both Vue 2 (options API) and Vue 3 (composition API), abstracting away the complexities of the reCAPTCHA JavaScript API, and offering optional loader configurations for advanced use cases.
npm install vue-recaptcha-v3Verified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the `vue-recaptcha-v3` plugin for Vue 3 using the Composition API, execute a reCAPTCHA action, and retrieve the token. It includes an optional environment variable for the site key and shows basic console logging of the token.
For Vue 2 applications, use `vue-recaptcha-v3` version `^1.9.0`. For Vue 3, ensure you are on `^2.0.0` or later. Adjust your `package.json` accordingly and reinstall dependencies.
Register your domain on the Google reCAPTCHA admin console to obtain a site key. Ensure the site key passed to `Vue.use(VueReCaptcha, { siteKey: '...' })` matches the one configured for your domain.Create a `shims-vue-recaptcha-v3.d.ts` file and extend `ComponentCustomProperties` from `@vue/runtime-core` as described in the package's documentation to provide proper type inference.
Always use the correct capitalization: `useReCaptcha` for the hook, and `executeRecaptcha` for the function returned by the hook. Refer to the latest package documentation for accurate symbol names.
For Vue 2 applications, downgrade `vue-recaptcha-v3` to a `^1.9.0` version. For Vue 3, ensure your application setup uses `createApp()` and the correct import for `VueReCaptcha`.
Ensure you pass a valid Google reCAPTCHA v3 site key to the `Vue.use(VueReCaptcha, { siteKey: 'YOUR_SITE_KEY' })` configuration object.Create a `shims-vue-recaptcha-v3.d.ts` file in your project with the provided type declarations from the package documentation to augment `ComponentCustomProperties`.