Pre-Clearance support for single-page applications
You can integrate Cloudflare challenges on single-page applications (SPAs) by allowing Turnstile to issue a Pre-Clearance cookie. The Pre-Clearance level is set upon widget creation or widget modification using the Turnstile API’s clearance_level
. Possible values for the configuration are no_clearance
, jschallenge
, managed
, or interactive
. All widgets are set to no_clearance
by default.
For Enterprise customers eligible to toggle off domain checks, Cloudflare recommends issuing Pre-Clearance cookies on widgets where at least one domain is specified.
Refer to the blog post for an example of Pre-Clearance implementation.
Pre-Clearance level options
Interactive: Interactive Pre-Clearance allows a user with a clearance cookie to not be challenged by Interactive, Managed Challenge, or JavaScript Challenge Firewall Rules
Managed: Managed allows a user with a clearance cookie to not be challenged by Managed Challenge or JavaScript Challenge Firewall Rules
Non-interactive: Non-interactive allows a user with a clearance cookie to not be challenged by JavaScript Challenge Firewall Rules
Duration
Clearance cookies generated by the Turnstile widget will be valid for the time specified by the zone-level Challenge Passage value. To configure the Challenge Passage setting, refer to the WAF documentation.
Enable Pre-Clearance on a new site
- Log in to the Cloudflare dashboard and select your account.
- Go to Turnstile > Add Site.
- Under Would you like to opt for Pre-Clearance for this site? select Yes.
- Choose the Pre-Clearance level from the select box.
- Select Create.
Enable Pre-Clearance on an existing site
- Log in to the Cloudflare dashboard and select your account.
- Go to Turnstile.
- Go to the existing widget or site and select Settings.
- Under Would you like to opt for Pre-Clearance for this site? select Yes.
- Choose the Pre-Clearance level from the select box.
- Select Update.