ReCaptcha component for GatsbyJS.
This plugin has been developed using GatsbyJS tutorials.
npm install @pittica/gatsby-plugin-recaptcha
Import the component classes.
import ReCaptcha from "@pittica/gatsby-plugin-recaptcha"
Use the component in React functions.
import React, { useState } from "react"
export default function ContactPage() {
const [submitted, setSubmitted] = useState(false)
const submit = (token) => {}
return (
<div>
<ReCaptcha
action="homepage"
siteKey="RECAPTCHA_PUBLIC_KEY"
onVerify={(token) => submit(token)}
submitted={submitted}
/>
<button onClick={() => setSubmitted(true)}>Submit</button>
</div>
)
}
The components has some attributes.
- Type: string
- Required: yes
ReCaptcha public key.
- Type: string
- Required: yes
- Default value: homepage
ReCaptcha action. Common values are homepage or login.
- Type: string
- Required: no
HTML ID for multiple ReCaptcha elements.
- Type: string
- Required: no
- Values: bottomright, bottomleft, inline
- Default value: inline
Badge position and aspect.
- Type: string
- Required: no
- Values: compact, normal, invisible
- Default value: invisible
Badge size.
- Type: function
- Required: no
Validation callback.
- Type: string
- Required: no
- Values: light, dark
- Default value: light
(c) 2020-2021, Pittica S.r.l..