Interface
Required Props
Your Cloudflare Turnstile sitekey. This sitekey is associated with the corresponding widget configuration and is created upon widget creation.Get your sitekey from the Cloudflare Dashboard.
Callback Props
Callback invoked after a successful render of the widget. The callback is passed the widget ID.Note: Does not trigger when the widget is reset.
Callback invoked upon successful completion of the challenge. The callback receives a token that can be validated on your server.See Server Validation for how to validate tokens.
Callback invoked when a challenge expires. The callback receives the expired token.
Callback invoked when there is an error (e.g., network error or challenge failure). The callback receives an error code.Refer to Client-side errors in the Cloudflare documentation.
Callback invoked before the user is prompted for interactivity.
Callback invoked when the interactive challenge has been solved.
Callback invoked when the browser is not supported by Turnstile.
Callback invoked when the Turnstile widget times out.
Configuration Props
Custom widget render options that control the appearance and behavior of the Turnstile widget.See ComponentRenderOptions for all available options.
Custom options for the injected Turnstile script, including nonce, defer, async, and more.See ScriptOptions for all available options.
Define the HTML tag of the widget container. Defaults to
'div'.Controls whether the Turnstile script is automatically injected. Set to
false if you want to inject the script manually.Callback invoked when the Turnstile script is loaded.
Controls whether the widget re-renders when callback props change.
false(default): Stable callbacks - better performance, callbacks don’t cause widget re-renderstrue: Dynamic callbacks - widget re-renders when callbacks change, useful for intentional callback updates
true, wrap your callback functions with useCallback to prevent unnecessary widget re-renders on every parent component re-render.HTML Attributes
SinceTurnstileProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onError'>, you can pass any standard HTML div attributes:
Related Types
- ComponentRenderOptions - Widget render options
- ScriptOptions - Script injection options
- TurnstileInstance - Ref methods interface