Device Trust
Device Trust is Clerk's defense against credential stuffing attacks - a type of attack where bad actors use lists of stolen passwords to attempt to gain unauthorized access to user accounts.
When Device Trust is enabled, Clerk treats every new device as untrusted until the user has verified their identity with a .
Enable Device Trust
Device Trust is off by default for applications created before November 14, 2025. Before turning it on:
- Turn on password sign-in. Device Trust only applies when password sign-in is enabled.
- Check your custom sign-in flow. If your flow accepts passwords, it must handle the
needs_client_truststatus. See Impact on custom sign-in flows.
Once your application meets these requirements, turn on Device Trust:
- In the Clerk Dashboard, navigate to the Sign-in security page under Protect.
- In the Device Trust row, select the settings icon.
- Toggle on Enable, then select Save.
How Device Trust works
Device Trust automatically requires a when all of the following conditions are met:
- The user enters a valid password.
- The user hasn't enabled multi-factor authentication (MFA).
- The user is signing in from a new device.
When these conditions are met, Clerk uses an email code, SMS code, or email link based on your settings. The user must complete this verification to finish the sign-in process.
- In the Clerk Dashboard, navigate to the Sign-in security page under Protect.
- In the Device Trust row, select the settings icon.
- Toggle off Enable, then select Save.
How long a device remains trusted
Device Trust doesn't have a separate, configurable trust duration. On web applications, Clerk recognizes a browser through the client authentication cookie, so the browser remains trusted for as long as that cookie remains present and valid.
If the cookie expires, is deleted, or is unavailable - for example, after the user clears their browser data, switches browser profiles, or starts a private browsing session without the existing cookie - Clerk treats the browser as a new device and may require second-factor verification again.
You can't configure the Device Trust duration in the Clerk Dashboard or for an individual sign-in attempt. To access the expiration time of the current client's authentication cookie, use the Client.cookieExpiresAt property:
const expiresAt = clerk.client.cookieExpiresAtFor development instances, this property is always null. For production instances, it reports the cookie's current expiration time, but can also be null. Clerk can refresh the client cookie, so this value can change. A user can also delete the cookie before it expires. If you display the value, describe it as the current cookie expiration time rather than a guaranteed Device Trust expiration date.
How it works with other protections
Device Trust helps when an attacker already has a user's correct password. Lock accounts after failed sign-ins covers the opposite case, where an attacker guesses at a password and gets it wrong. Reject compromised passwords makes users replace passwords that have appeared in data breaches, which are the passwords credential stuffing relies on.
Impact on custom sign-in flows
If you've built a that allows password-based sign-ins using the Clerk API or SDKs, you'll need to handle the needs_client_trust status that Device Trust can trigger.
When Device Trust requires verification, the sign-in attempt will return a status of needs_client_trust with email_code, phone_code, or email_link in the supportedSecondFactors array. Your flow should:
- Check if the sign-in status is
needs_client_trust. - Check if
email_code,phone_code, oremail_linkis in thesupportedSecondFactorsarray. - Call
prepareSecondFactor()for the selected strategy. - Complete the selected strategy's verification.
- If successful, set the session as active.
For a complete implementation example, see the email/password custom flow guide.
After the user enters their password, the sign-in's clientTrustState property reports whether Clerk trusts the device for the user. Use it to record Device Trust outcomes in your analytics. It's one of the following values:
'new': Clerk doesn't trust the device for the user yet, or can't confirm that it does. While the status isneeds_client_trust, the value is'new'.'known': Clerk trusts the device for the user because the user signed up or completed a sign-in on it before, with or without a second factor.'pending': Clerk has no identifier or account to check the device against. A password sign-in never returns this value once the password is verified.
With the Device Trust Status update and an SDK that supports the needs_client_trust status, Clerk returns the value only after the first factor, such as the password, is verified, so entering an identifier doesn't reveal whether that account has signed in on the device. Before then, the value is undefined. Otherwise, Clerk returns the value on every response. When Device Trust is off, the value is undefined.
The following example uses the signIn object returned by useSignIn(). It demonstrates how to read the value after the user submits their password:
const { error } = await signIn.password({ emailAddress, password })
if (error) {
console.error(JSON.stringify(error, null, 2))
return
}
// Read the value after the password
const clientTrustState = signIn.clientTrustStateUse the value together with the sign-in's status:
- If the status is
needs_client_trust, the value is'new', and Clerk asks for a second factor to verify the device before the sign-in completes. - If the status is
needs_second_factor, the user has MFA, or your application hasn't opted in to the Device Trust Status update.'known'means Clerk trusted the device before this sign-in, and'new'means it didn't or couldn't confirm that it did. - If the status is
needs_new_password, the user must set a new password before the sign-in completes.'known'means Clerk trusted the device before this sign-in, and'new'means it didn't or couldn't confirm that it did. - If the status is
complete, the value is usually'known', because Clerk either already trusted the device or trusted it when the sign-in completed. Clerk trusts the device on completion even when it couldn't verify it, for example for a user who has no verified email address or phone number. The value is'new'instead when the user signed in with an email address or phone number that isn't verified. - If the value is
undefinedafter the first factor is verified and your SDK meets the minimum version, Device Trust is off.
If you use the legacy SignIn object, read signIn.clientTrustState after signIn.attemptFirstFactor({ strategy: 'password', password }), or after signIn.create() when you pass the password with the identifier.
Limitations
- Password-only: Device Trust only applies to password-based sign-ins. Passwordless authentication methods (such as email link sign-ins, , passkeys, and OAuth) are not affected.
- Email/Phone number required: Device Trust requires the user to have a verified email address or phone number to receive the verification.
Feedback
Last updated on