Files
2026-08-03 12:24:28 +02:00

31 lines
1.2 KiB
TypeScript

declare global {
interface Window {
turnstile?: {
render: (el: HTMLElement, opts: Record<string, unknown>) => string;
reset: (id?: string) => void;
};
}
}
export type TurnstileProps = {
/** Called with the token once solved, or null on expiry/error. */
onToken: (token: null | string) => void;
/**
* Public Turnstile site key. The client project reads it server-side from
* SiteIntegrations (turnstileSiteKey) and passes it in — the widget is a pure
* client component and can't read Payload itself.
*/
siteKey: string;
theme?: 'auto' | 'dark' | 'light';
};
/**
* Cloudflare Turnstile widget — reusable across any form. Renders the challenge
* and reports the token via onToken. The token must then be verified
* server-side (see verifyTurnstile) before a submission is trusted.
*
* siteKey is a prop rather than an env var so all Turnstile config lives in one
* place (SiteIntegrations), consistent with the plugin's panel-managed model.
* The script is injected directly (no next/script dependency) so the widget
* stays framework-agnostic.
*/
export declare function Turnstile({ onToken, siteKey, theme }: TurnstileProps): import("react/jsx-runtime").JSX.Element | null;