1.0.4 • Published 10 months ago
@microalien/react-google-recaptcha v1.0.4
@microalien/react-google-recaptcha
🚀 About
@microalien/react-google-recaptcha is a lightweight, reusable React component for integrating Google reCAPTCHA v3 in Next.js 15.2 and React 19 applications without using third-party libraries.
✨ Features
- ✅ Supports Google reCAPTCHA v3
- ✅ Works with Next.js 15.2 & React 19
- ✅ Fully typed with TypeScript support
- ✅ Simple API for token retrieval
- ✅ Automatically loads reCAPTCHA script
- ✅ Optimized for performance and security
📦 Installation
To install the package, run:
npm install @microalien/react-google-recaptchaor with yarn:
yarn add @microalien/react-google-recaptcha🛠️ Usage
1️⃣ Import and Use the ReCaptcha Component
'use client';
import ReCaptcha from '@microalien/react-google-recaptcha';
export default function MyComponent() {
const handleToken = (token: string) => {
console.log('reCAPTCHA Token:', token);
};
return (
<ReCaptcha sitekey={process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY} onToken={handleToken}>
<button>Submit</button>
</ReCaptcha>
);
}2️⃣ Retrieve reCAPTCHA Token Manually
You can also get the token programmatically:
import { getReCaptchValue } from '@microalien/react-google-recaptcha';
const token = await getReCaptchValue(sitekey);
console.log('reCAPTCHA Token:', token);🔗 Environment Variables
Make sure to set your Google reCAPTCHA v3 site key in .env.local:
NEXT_PUBLIC_RECAPTCHA_SITE_KEY=your-site-key-here🎯 Compatibility
| Framework | Supported |
|---|---|
| React 19 | ✅ |
| Next.js 15.2 | ✅ |
| TypeScript | ✅ |
🛠️ Development
To contribute or modify the package:
git clone https://github.com/microalien/react-google-recaptcha.git
cd react-google-recaptcha
npm install
npm run build📜 License
MIT License © 2025 Tarun Bhardwaj