Skip to main content

Note

This protection is included on every plan, and it's on by default for applications created after November 14, 2025.

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_trust status. See Impact on custom sign-in flows.

Once your application meets these requirements, turn on Device Trust:

  1. In the Clerk Dashboard, navigate to the Sign-in security page under Protect.
  2. In the Device Trust row, select the settings icon.
  3. Toggle on Enable, then select Save.

How Device Trust works

Device Trust automatically requires a when all of the following conditions are met:

  1. The user enters a valid password.
  2. The user hasn't enabled multi-factor authentication (MFA).
  3. 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.

Note

If the user has already enabled MFA (such as an authenticator app or SMS verification), Device Trust will not trigger - their existing MFA method will be used instead.

How Device Trust differs from traditional MFA

AspectDevice TrustTraditional MFA
TriggerAutomatic on new devicesUser must enable it
Verification methodEmail code, SMS code, or email linkTOTP, SMS code, backup codes
User setup requiredNoneUser must configure their preferred method
When it appliesOnly for password sign-insAll sign-ins

Turn off Device Trust

Warning

We recommend keeping Device Trust on because it adds a second-factor check when someone signs in with a valid password on a new device and hasn't set up MFA. Turning it off removes that check for those sign-ins.

  1. In the Clerk Dashboard, navigate to the Sign-in security page under Protect.
  2. In the Device Trust row, select the settings icon.
  3. Toggle off Enable, then select Save.

Note

If password sign-in is disabled, the settings icon opens Additional setup required instead of the Device Trust toggle. Device Trust does not apply without password sign-in. If you enable password sign-in later, use the steps above to turn off Device Trust.

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.cookieExpiresAt

For 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.

Note

Device Trust is automatic and Clerk doesn't provide a supported per-sign-in option for changing how long a browser remains trusted. If you build a custom sign-in UI, use informational text to explain how long the browser can remain recognized instead of presenting a "Remember this device" checkbox as a Device Trust setting.

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.

Note

Device Trust was previously called "Client Trust." The feature was renamed, but its API values - including the needs_client_trust status - kept their original names so that existing integrations keep working.

If an older application has Device Trust enabled but your custom sign-in flow receives the legacy needs_second_factor status instead of needs_client_trust, opt in to the Device Trust Status update on the Updates page. This update doesn't enable Device Trust. It only changes the custom-flow response from needs_second_factor to needs_client_trust.

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:

  1. Check if the sign-in status is needs_client_trust.
  2. Check if email_code, phone_code, or email_link is in the supportedSecondFactors array.
  3. Call prepareSecondFactor() for the selected strategy.
  4. Complete the selected strategy's verification.
  5. If successful, set the session as active.

For a complete implementation example, see the email/password custom flow guide.

Tip

If your application supports both Device Trust and user-enabled MFA, make sure to handle both the needs_client_trust and needs_second_factor statuses. The needs_client_trust status is returned when Device Trust triggers on a new device, while needs_second_factor is returned when the user has MFA enabled on their account.

Important

To read clientTrustState from the signIn object returned by useSignIn(), use one of the following Clerk SDK versions:

  • @clerk/nextjs v7.10.3 or higher
  • @clerk/react v6.19.0 or higher
  • @clerk/expo v4.17.0 or higher
  • @clerk/tanstack-react-start v1.7.15 or higher
  • @clerk/react-router v3.7.4 or higher
  • @clerk/chrome-extension v3.1.109 or higher
  • @clerk/electron v0.1.14 or higher

On older versions, clientTrustState is missing from the types and can read undefined even when Device Trust is on.

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 is needs_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.clientTrustState

Use 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 undefined after 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

What did you think of this content?

Last updated on