Prerequisites
- You need to have the Dynamic Client initialized.
- You need to have device registration enabled in your environment’s settings in the Dynamic Dashboard.
- JavaScript SDK v2 or later.
Checking if device registration is required
After a user authenticates, check whether their current device needs to be registered. This is determined by thedevice:register scope in the user’s session.
Completing device registration
When the user clicks the verification link in their email, they are redirected back to your app with a token in the URL. You need to detect this redirect and complete the registration.Listening for events
You can listen for device registration events to update your UI accordingly.Getting registered devices
Retrieve all trusted devices for the current user.| Field | Type | Description |
|---|---|---|
id | string | The device registration ID |
createdAt | string | ISO date of when the device was registered |
userAgent | string | The browser or device user agent |
isCurrentDevice | boolean | Whether this is the device making the request |
Displaying devices
You can useparseUserAgent to display a friendly device name from the raw user agent string.
Revoking a device
Remove a single trusted device. If the revoked device is the current device, the user will be logged out.Revoking all devices
Remove all trusted devices for the current user. This always logs the user out.Related
- Device Registration Overview — How device registration works and why it matters
- Security Overview — Dynamic’s security posture