@nanlabs/react-thirdparty
v0.4.0
Published
<!--lint disable double-link awesome-heading awesome-git-repo-age awesome-toc-->
Downloads
5
Readme
This library provides a set of React components that can be used in any React application. It provides integrations with third party libraries like Google ReCaptcha and more!
This library uses @nanlabs/thirdparty under the hood. You can check it out if you want to use the integrations in a non-React application.
Installation
npm install @nanlabs/react-thirdparty
Usage
The following example shows how one of the multiple integrations provided by this library can be used.
In the example bellow we use GoogleReCaptchaProvider
and useGoogleReCaptcha
to integrate reCAPTCHA v3 in our application.
You can find more examples in the documentation.
import React, { useState } from "react";
import {
GoogleReCaptchaProvider,
useGoogleReCaptcha,
} from "@nanlabs/react-thirdparty";
// Your component that wants to use reCAPTCHA
const YourReCaptchaComponent = () => {
const [token, setToken] = useState();
return (
<GoogleReCaptcha
action="login_page"
onVerify={(token) => {
setToken(token);
}}
/>
);
};
// Use the provider in your app to configure the reCAPTCHA library
const App = () => (
<GoogleReCaptchaProvider reCaptchaKey="YOUR_RECAPTCHA_KEY">
<YourReCaptchaComponent />
</GoogleReCaptchaProvider>
);