reCAPTCHA setup for website form protection

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:
Development stages
Latest works
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    847
  • image_website-sbh_0.png
    Website development for SBH Partners
    999
  • image_website-_0.png
    Website development for Red Pear
    451

reCAPTCHA Setup for Website Form Protection

Google reCAPTCHA protects forms from automated bots: spam account registrations, password brute force, mass form submissions. Three versions with different UX trade-offs exist.

reCAPTCHA Versions

v2 Checkbox — classic "I'm not a robot". User checks box, sometimes passes visual test.

v2 Invisible — requires no interaction, analyzes behavior in background. Shows challenge on suspicion.

v3 — completely invisible, returns score 0.0 to 1.0. Developer decides what to do on low score.

Registration and Keys

Get keys from google.com/recaptcha/admin. Need site_key (public, for frontend) and secret_key (private, server only).

reCAPTCHA v3 Integration

Frontend:

<script src="https://www.google.com/recaptcha/api.js?render=SITE_KEY"></script>
<script>
grecaptcha.ready(function() {
    document.getElementById('submit').addEventListener('click', async function(e) {
        e.preventDefault();
        const token = await grecaptcha.execute('SITE_KEY', {action: 'contact_form'});
        document.getElementById('recaptcha-token').value = token;
        document.getElementById('myForm').submit();
    });
});
</script>
<input type="hidden" id="recaptcha-token" name="recaptcha_token">

Server verification (PHP):

$token = $request->input('recaptcha_token');
$secret = config('services.recaptcha.secret');

$response = Http::post('https://www.google.com/recaptcha/api/siteverify', [
    'secret'   => $secret,
    'response' => $token,
    'remoteip' => $request->ip(),
]);

$data = $response->json();

if (!$data['success'] || $data['score'] < 0.5 || $data['action'] !== 'contact_form') {
    abort(422, 'reCAPTCHA verification failed');
}

Score Strategy for reCAPTCHA v3

Score Interpretation Action
0.9–1.0 Obviously human Pass
0.5–0.9 Probably human Pass
0.3–0.5 Undefined Additional check / email confirmation
0.0–0.3 Probably bot Block or show v2 Checkbox

React Integration

import ReCAPTCHA from 'react-google-recaptcha';

function ContactForm() {
    const recaptchaRef = useRef(null);

    const handleSubmit = async (e) => {
        e.preventDefault();
        const token = await recaptchaRef.current.executeAsync();
        recaptchaRef.current.reset();
        // Send token with form data
        await submitForm({ ...formData, recaptcha_token: token });
    };

    return (
        <form onSubmit={handleSubmit}>
            {/* form fields */}
            <ReCAPTCHA
                ref={recaptchaRef}
                sitekey={process.env.REACT_APP_RECAPTCHA_SITE_KEY}
                size="invisible"
            />
            <button type="submit">Submit</button>
        </form>
    );
}

Implementation Timeline

Basic reCAPTCHA v3 integration — 4–8 hours including server verification.