Skip to main content

google-recaptcha-v2

A Reflex custom component google-recaptcha-v2.

Installation

pip install reflex-google-recaptcha-v2

Usage

Set your site key and secret key in your environment variables.

export RECAPTCHA_SITE_KEY="your-site-key"
export RECAPTCHA_SECRET_KEY="your-secret-key"

Alternatively, you can set the keys via python functions as seen in the demo app.

These keys can be obtained at Google's Recaptcha Portal. To access the secret key, which is required, go to the Integration tab and select "Use legacy key" or "I'm integrating with a third party library".

Place the Recaptcha component

import reflex as rx

from reflex_google_recaptcha_v2 import google_recaptcha_v2

def index():
    return rx.vstack(
        ...,
        google_recaptcha_v2(),
    )

Verify the Recaptcha response

Before taking actions on the backend, you should verify that the user browser has passed validation of the token.

This value will be set for the specific tab that has completed validation and persists for the lifetime of the Reflex session (until the tab is closed).

import reflex as rx

from reflex_google_recaptcha_v2 import GoogleRecaptchaV2State


class MyState(rx.State):
    form_error: str

    async def handle_submit(self, form_data):
        ...
        recaptcha_state = await self.get_state(GoogleRecaptchaV2State)
        if not recaptcha_state.token_is_valid:
            self.form_error = "Invalid recaptcha. Are you a robot?"
            return

Release files for reflex-google-recaptcha-v2 0.1.0.post1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for reflex-google-recaptcha-v2 0.1.0.post1
File Size Uploaded
reflex_google_recaptcha_v2-0.1.0.post1.tar.gz 8.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for reflex-google-recaptcha-v2 0.1.0.post1
File Interpreter ABI Platform
reflex_google_recaptcha_v2-0.1.0.post1-py3-none-any.whl Python 3 none any Details

Total release size: 13.2 kB

Release files / reflex_google_recaptcha_v2-0.1.0.post1.tar.gz

Download URL reflex_google_recaptcha_v2-0.1.0.post1.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
43a22f2a35e6c7498ce4f2f2630281528d3888338652f2afd125414839b0ef8c
BLAKE2b-256 checksum
How to use checksums
b414b69929d6c553a25a32ee36eb38f6db7ea15a046c166eed39d39e52cdf7cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / reflex_google_recaptcha_v2-0.1.0.post1-py3-none-any.whl

Download URL reflex_google_recaptcha_v2-0.1.0.post1-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
12264cfc6e20789d3ec68440caf7a2c07fb44ef479e42f16ee5b078b266830ec
BLAKE2b-256 checksum
How to use checksums
a0aed93c2e6a7a50fdd0b8e739de4d392a19f9d6191a0a25ef91eddcb8bb6097
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.1.0.post1 This release

2 release files

0.1.0

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page