Interface
Usage
Pass these options via thescriptOptions prop:
Options
Custom nonce for the injected script. Used for Content Security Policy (CSP) compliance.Example with CSP:
Whether to set the injected script as deferred. Deferred scripts execute after the document has been parsed.
Whether to set the injected script as async. Async scripts execute as soon as they’re loaded.
Where to inject the script in the document.
'head': Appends to<head>element'body': Appends to<body>element
Custom ID for the injected script element. Useful for identifying the script in the DOM.
Custom name for the global onload callback function. This function is called when the Turnstile script loads.
Callback invoked when the script fails to load (e.g., Cloudflare has an outage).
Custom
crossOrigin attribute for the injected script.Accepted values: 'anonymous', 'use-credentials'Common Scenarios
Content Security Policy (CSP)
When using CSP, you need to provide a nonce:Manual Script Injection
If you want to inject the script manually:Error Handling
Handle script loading errors gracefully:Optimizing Load Performance
Default Script URL
The Turnstile script is loaded from:onload: The callback function namerender:'explicit'(controlled by the library)
Constants
The following constants are exported and can be imported:Related Types
- TurnstileProps - Component props
- Constants - Exported constants