FriendlyCaptcha React Implementation
npm install @aacn.eu/use-friendly-captchauseCaptchaHook() in your selected file. From there you can then query the widgetPlease be aware that the friendly-challenge library is a necessary peer dependency since version 1.2.0
The hook expects the following properties:
```
siteKey: string;
endpoint?: FC_PUZZLE_EP; enum for the currently available endpoints (EU & global)
language?: keyof typeof localizations | Localization;
startMode?: "auto" | "focus" | "none";
showAttribution: boolean;CaptchaWidget
The hook provides the following parameters:
- returns the HTML authentification widget.captchaStatus.solution
- is used to determine if the puzzle was already solved (string) or not (null)captchaStatus.error
- is used to determine if an error occured while solving (string) or not (null)
CaptchaWidget custom props
When the CaptchaWidget gets rendered, you can add additional properties:props: HTMLAttributes This includes all possible html attributes. Therefor this is the entry point to add the className attribute,customWidgetStyle
to add custom styling to the outer captcha container. Here can you either directly add TailwindCSS classes or define a custom class for
future styling in the .css file of the project. allows up to three attributes for specific stylings that are directly applied to the components:icon
- The icon of the widgetbutton
- The submit button of the widgettext
- All text elements that appear inside the widget`
These attributes are all optional and if used, they expect a css object like the following example:js`
CustomWidgetStyle = { icon: {color: "green", background: "yellow"}, text: {color: "blue"} }
The function expects the following properties:
``
endpoint?: FC_VERIFICATION_EP; enum for the currently available endpoints (EU & global)
solution: string;
secret: string;
sitekey?: string;
httpPostFetcher: (see further down)
function fetcherExample(
endpoint: string,
requestBody: { solution: string; secret: string; siteKey: string },
headers: { 'Content-Type': 'application/json'; 'Accept': 'application/json'; }
) => Promise<{ success: boolean; errors: any; } | null>
`$3
We provided basic examples in the /examples` folder, on how to use this library in React and Nextjs.