Register WebAuthn for a logged-in user
The login form automatically prompt the user to register WebAuthn, however, it's possible that the user dismissed it.
The following guide only works with Cotter's NPM package that can be installed using:
yarn add cotter
<!-- or -->
npm i cotter --save
<!-- or -->
src="[email protected]/dist/cotter.min.js"
This feature is not supported on imports using
<script src="" type="text/javascript"></script>
To add the option to register WebAuthn in your Settings page, you can do the following:

1. Check if WebAuthn is available

WebAuthn is supported in some browsers like Google Chrome, but not all browsers and not all devices supports it. Do the following to decide whether or not to show the button to setup WebAuthn:
// 1) Check if WebAuthn is available
Cotter.isWebAuthnAvailable().then(available =>

2. Register this device for WebAuthn

If WebAuthn is available, you can register WebAuthn for the user on button press:
var cotter = new Cotter(API_KEY_ID)
var user = cotter.getLoggedInUser() // Get the logged-in user
if (user) { // If there's a logged-in user
.registerWebAuthn() // register WebAuthn
.then(resp => console.log(resp))
.catch(err => console.log(err))
Copy link