<Turnstile /> component accepts a variety of props to customize its behavior, appearance, and lifecycle callbacks. This page documents all available props extracted from the source code.
Required Props
Your Cloudflare Turnstile sitekey. This sitekey is associated with the corresponding widget configuration and is created upon the widget creation.
Callback Props
Callbacks are invoked at different stages of the widget lifecycle.Callback invoked upon success of the challenge. The callback is passed a token that can be validated on your server.
Callback invoked when there is an error (e.g., network error or the challenge failed). The callback is passed an error code.See Client-side errors for error codes.
Callback invoked when a challenge expires. Tokens expire after a certain duration and need to be refreshed.
Callback invoked when the Turnstile widget times out.
Callback invoked before the user is prompted for interactivity. Useful for showing loading states.
Callback invoked when the interactive challenge has been solved.
Callback invoked when the browser is not supported by Turnstile.
Callback invoked after a successful render of the widget. The callback is passed the widget ID. It does not trigger when the widget is reset.
Widget Options
Theoptions prop accepts a ComponentRenderOptions object to configure the widget’s appearance and behavior.
Custom widget render options. See individual properties below.
Appearance Options
The widget theme. The default is
"auto", which respects the user preference.The size of the Turnstile widget:
normal: 300x65pxcompact: 150x140pxflexible: 100% width (min: 300px) x 65pxinvisible: No widget shown (only for invisible type widgets)
The appearance mode of the Turnstile widget:
always: Widget is always visibleexecute: Widget only appears when executinginteraction-only: Widget only shown when/if interactivity is required
The language for the widget. Must be a valid ISO 639-1 country code, or
"auto" to detect automatically.Supported languages include: 'en', 'es', 'fr', 'de', 'ja', 'zh', and many more.Behavior Options
Execution controls when to obtain the token of the widget:
render: Token obtained automatically on render (default)execute: Token obtained only when.execute()is called
How to retry on widget failure:
auto: Allows the user to retrynever: No retry option
Duration in milliseconds before the widget automatically retries.
The refresh mode to use when the given Turnstile token expires:
auto: Automatically refreshes the widgetmanual: Prompts the user with a refresh buttonnever: Never refreshes the widget
The refresh mode to use when the widget times out:
auto: Automatically refreshes the widgetmanual: Prompts the user with a refresh buttonnever: Never refreshes the widget
Data Options
A customer value that can be used to differentiate widgets under the same sitekey in analytics and which is returned upon validation.
A customer payload that can be used to attach customer data to the challenge throughout its issuance and which is returned upon validation.
Accessibility & Form Options
The tabindex of Turnstile’s iframe for accessibility purposes.
Whether to add or not a hidden response input element with the turnstile token. Useful for form submissions.
The name of the hidden input element added to the container where Turnstile is injected.
Allows Cloudflare to gather visitor feedback upon widget failure.
Script Control Props
Controls if the script is automatically injected or not. If you want to inject the script manually, set this property to
false.See Script Injection for more details.Callback invoked when the Turnstile script is loaded.
Custom injected script options. See Script Injection for details.
Advanced Props
Define the HTML tag of the widget container.
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
Important: When set to
true, wrap your callback functions with useCallback to prevent unnecessary widget re-renders on every parent component re-render.HTML Attributes
The component extendsReact.HTMLAttributes<HTMLDivElement>, so you can pass any standard HTML attributes (except onError, which is reserved for the Turnstile callback):
Common Prop Combinations
Form Integration
Form Integration
Perfect for form submissions with hidden field:
Invisible Widget
Invisible Widget
No UI, programmatic execution:
Dark Theme with Manual Refresh
Dark Theme with Manual Refresh
Custom appearance with manual token refresh:
Error Handling
Error Handling
Comprehensive error and timeout handling: