@hcaptcha/react-native-hcaptcha

hCaptcha Library for React Native (both Android and iOS)

Usage no npm install needed!

<script type="module">
  import hcaptchaReactNativeHcaptcha from 'https://cdn.skypack.dev/@hcaptcha/react-native-hcaptcha';
</script>

README

react-native-hcaptcha

hCaptcha wrapper for React Native (Android and iOS)

Installation

  1. Install package:
  • Using NPM npm install react-native-hcaptcha
  • Using Yarn yarn add react-native-hcaptcha
  1. Import package: import ConfirmHcaptcha from '@hcaptcha/react-native-hcaptcha';

Demo

See live demo in Snack.

Usage

See Example.App.js example in repo for a fully worked example implementation.

Dependencies

  1. react-native-modal

  2. react-native-webview

Localization

Make sure the value you pass to languageCode is the one the user has set in your app if you allow them to override the system defaults.

Otherwise, you should pass in the preferred device locale, e.g. fetched from getLocales() if using react-native-localize.

Note

You can import Hcaptcha from '@hcaptcha/react-native-hcaptcha/Hcaptcha'; to customize the UI yourself.

Properties

  • siteKey (String) - The hCaptcha sitekey
  • baseUrl (String) The url domain defined on your hCaptcha. You generally will not need to change this.
  • onMessage (Function) - The callback function that runs after receiving a response, error, or when user cancels.
  • languageCode (String) - Default language for hCaptcha. Overrides phone defaults. A complete list of supported languages and their codes can be found at this link

Status

Fully functional, but additional releases will be made in the near term. Changes within the same major release are expected to be additive, i.e. non-breaking.

TODOs:

  • Replace api.js params with more flexible constructor.
  • Support rqdata and other hCaptcha Enterprise features.

License

MIT License. (C) 2021 hCaptcha.

Credits: Originally forked from xuho and filipepiresg's Google reCAPTCHA v2 work. (MIT license)