🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

@types/react-google-recaptcha

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
D

@types/react-google-recaptcha

TypeScript definitions for react-google-recaptcha

2.1.9
ts4.6
ts4.7
ts4.8
ts4.9
ts5.0
ts5.1
ts5.2
ts5.3
ts5.4
ts5.5
ts5.6
ts5.7
ts5.8
ts5.9
latest
100

Supply Chain Security

100

Vulnerability

69

Quality

76

Maintenance

100

License

Version published
Weekly downloads
414K
-10.93%
Maintainers
1
Weekly downloads
 
Created
Issues
707

What is @types/react-google-recaptcha?

@types/react-google-recaptcha provides TypeScript definitions for the react-google-recaptcha package, which is a React component wrapper for Google reCAPTCHA. This package allows developers to easily integrate Google reCAPTCHA into their React applications with type safety.

What are @types/react-google-recaptcha's main functionalities?

Rendering reCAPTCHA

This feature allows you to render a Google reCAPTCHA widget in your React component. You can specify the site key and handle the onChange event to capture the reCAPTCHA value.

import ReCAPTCHA from 'react-google-recaptcha';

function MyComponent() {
  const recaptchaRef = React.createRef();

  return (
    <ReCAPTCHA
      ref={recaptchaRef}
      sitekey="your-site-key"
      onChange={(value) => console.log('Captcha value:', value)}
    />
  );
}

Executing reCAPTCHA programmatically

This feature allows you to execute the reCAPTCHA programmatically, which is useful for invisible reCAPTCHA. You can call the execute method on the reCAPTCHA ref to trigger the verification process.

import ReCAPTCHA from 'react-google-recaptcha';

function MyComponent() {
  const recaptchaRef = React.createRef();

  const handleClick = () => {
    recaptchaRef.current.execute();
  };

  return (
    <div>
      <ReCAPTCHA
        ref={recaptchaRef}
        sitekey="your-site-key"
        size="invisible"
        onChange={(value) => console.log('Captcha value:', value)}
      />
      <button onClick={handleClick}>Verify</button>
    </div>
  );
}

Resetting reCAPTCHA

This feature allows you to reset the reCAPTCHA widget programmatically. You can call the reset method on the reCAPTCHA ref to reset the widget and clear the current response.

import ReCAPTCHA from 'react-google-recaptcha';

function MyComponent() {
  const recaptchaRef = React.createRef();

  const handleReset = () => {
    recaptchaRef.current.reset();
  };

  return (
    <div>
      <ReCAPTCHA
        ref={recaptchaRef}
        sitekey="your-site-key"
        onChange={(value) => console.log('Captcha value:', value)}
      />
      <button onClick={handleReset}>Reset</button>
    </div>
  );
}

Other packages similar to @types/react-google-recaptcha

FAQs

Package last updated on 23 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts