You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/props.mdx
+4-3Lines changed: 4 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -13,12 +13,13 @@ These are the props you can pass to the `Turnstile` component.
13
13
|`scriptOptions`| object | You can customize the injected `script` tag with this prop. It allows you to add `'async'`, `'defer'`, `'nonce'` attributes to the script tag. You can also control whether the injected script will be added to the document body or head with `appendTo` attribute. More info about this options [below](/props#scriptoptions-prop). ||
14
14
|`onSuccess`| function | Callback invoked upon success of the challenge. The callback is passed a token that can be validated. ||
15
15
|`onExpire`| function | Callback invoked when a challenge expires. Read the [Cloudflare docs](https://developers.cloudflare.com/turnstile/get-started/client-side-rendering/#refreshing-a-widget) for more info about handling expired widgets. ||
16
-
|`onError`| function | Callback invoked when there is an error (e.g. network error or the challenge failed). ||
16
+
|`onError`| function | Callback invoked when there is an error (e.g. network error or the challenge failed). Refer to [Client-side errors](https://developers.cloudflare.com/turnstile/reference/client-side-errors). ||
17
17
|`onBeforeInteractive`| function | Callback invoked before the challenge enters interactive mode. ||
18
18
|`onAfterInteractive`| function | Callback invoked when challenge has left interactive mode. ||
19
19
|`onUnsupported`| function | Callback invoked when a given client/browser is not supported by Turnstile. ||
20
20
|`as`| string | Define the HTML tag of the widget container. Default to `'div'`. ||
21
-
|`injectScript`| boolean | Controls if the script is automatically injected or not. If you want to inject the script manually, set this property to `false`. Default to `true`. ||
21
+
|`injectScript`| boolean | Controls if the script is automatically injected or not. If you want to inject the script manually, set this property to `false`. Default to `true`. ||
22
+
|`onLoadScript`| function | Callback invoked when the script is injected and loaded. ||
22
23
23
24
<Info>
24
25
You can pass any valid HTML prop such as `className`, `id`, or `style`, based on the `as` prop.
@@ -31,7 +32,7 @@ These are the props you can pass to the `Turnstile` component.
31
32
|`action`| string |`undefined`| A customer value that can be used to differentiate widgets under the same `sitekey` in analytics and which is returned upon validation. This can only contain up to 32 alphanumeric characters including `_` and `-`. |
32
33
|`cData`| string |`undefined`| A customer payload that can be used to attach customer data to the challenge throughout its issuance and which is returned upon validation. This can only contain up to 255 alphanumeric characters including `_` and `-`. |
33
34
|`theme`| string |`'auto'`| The widget theme. You can choose between `'light'`, `'dark'` or `'auto'`. |
34
-
|`language`| string |`'auto'`| Language to display, must be either: `auto` (default) to use the language that the visitor has chosen, or an ISO 639-1 two-letter language code (e.g. `en`) or language and country code (e.g. `pt-BR`). The following languages are currently supported: `ar-EG`, `de`, `en`, `es`, `fa`, `fr`, `id`, `it`, `ja`, `ko`, `nl`, `pl`, `pt-BR`, `ru`, `tr`, `zh-CN` and `zh-TW`. |
35
+
|`language`| string |`'auto'`| Language to display, must be either: `auto` (default) to use the language that the visitor has chosen, or an ISO 639-1 two-letter language code (e.g. `en`) or language and country code (e.g. `en-US`). Refer to the [list of supported languages](https://developers.cloudflare.com/turnstile/reference/supported-languages/) for more information. |
35
36
|`tabIndex`| number |`0`| The `tabindex` of Turnstile’s iframe for accessibility purposes. |
36
37
|`responseField`| boolean |`true`| A boolean that controls if an input element with the response token is created. |
37
38
|`responseFieldName`| string |`'cf-turnstile-response'`| Name of the input element. |
Copy file name to clipboardExpand all lines: docs/use-ref-methods.mdx
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,7 @@ The library exposes some methods within the `Turnstile` ref, in order to interac
13
13
|`remove()`| Removes the widget. Useful when a widget is no longer needed. This will not call any callback and will remove all related DOM elements. | void |
14
14
|`render()`| Renders the widget. Since all widgets are rendered automatically, this only takes effect if the widget was previously removed. If the widget is already rendered, this method will not re-render the widget. | void |
15
15
|`execute()`| If `options.execution` is set to `'execute'`, this method is used to render the widget. If the widget is already shown (rendered and executed), this method will not re-render the widget. If the widget got removed (`.remove()`), you need to call `.render()` and then `.execute()`. If `options.execution` is set to `'render'` (default), this method takes no effect. | void |
16
+
|`isExpired()`| Returns `true` if the widget has expired. | boolean |
Copy file name to clipboardExpand all lines: packages/lib/src/types.ts
+24-2Lines changed: 24 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -39,6 +39,13 @@ interface _Turnstile {
39
39
* @returns The token response.
40
40
*/
41
41
getResponse: (id?: string)=>string|undefined
42
+
43
+
/**
44
+
* Check if a widget is expired.
45
+
* @param id - Optional. ID of the widget to check, if not provided will target the last rendered widget.
46
+
* @returns `true` if the widget is expired, `false` otherwise.
47
+
*/
48
+
isExpired: (id?: string)=>boolean
42
49
}
43
50
44
51
/* Same as _Turnstile but without custom widget IDs. */
@@ -69,6 +76,12 @@ interface TurnstileInstance {
69
76
* @returns The token response.
70
77
*/
71
78
getResponse: ()=>string|undefined
79
+
80
+
/**
81
+
* Check if the current rendered widget is expired.
82
+
* @returns `true` if the widget is expired, `false` otherwise.
83
+
*/
84
+
isExpired: ()=>boolean|undefined
72
85
}
73
86
74
87
interfaceRenderOptions{
@@ -96,7 +109,7 @@ interface RenderOptions {
96
109
callback?: (token: string)=>void
97
110
98
111
/**
99
-
* Callback invoked when there is an error (e.g. network error or the challenge failed).
112
+
* Callback invoked when there is an error (e.g. network error or the challenge failed). Refer to [Client-side errors](https://developers.cloudflare.com/turnstile/reference/client-side-errors).
100
113
*/
101
114
'error-callback'?: ()=>void
102
115
@@ -133,7 +146,7 @@ interface RenderOptions {
133
146
theme?: TurnstileTheme
134
147
135
148
/**
136
-
* Language to display, must be either: `auto` (default) to use the language that the visitor has chosen, or an ISO 639-1 two-letter language code (e.g. `en`).
149
+
* Language to display, must be either: `auto` (default) to use the language that the visitor has chosen, or an ISO 639-1 two-letter language code (e.g. `en`) or language and country code (e.g. `en-US`). Refer to the [list of supported languages](https://developers.cloudflare.com/turnstile/reference/supported-languages/) for more information.
0 commit comments