# 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.&#x20;

{% hint style="warning" %}
The following guide only works with [Cotter's NPM package](https://www.npmjs.com/package/cotter) that can be installed using:

```markup
yarn add cotter

<!-- or -->

npm i cotter --save

<!-- or -->

<script
    src="https://unpkg.com/cotter@0.3.10-beta.5/dist/cotter.min.js"
    type="text/javascript"
></script>
```

This feature is **not supported** on imports using

```markup
<script src="https://js.cotter.app/lib/cotter.js" type="text/javascript"></script>
```

{% endhint %}

**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:**

```javascript
// 1) Check if WebAuthn is available
Cotter.isWebAuthnAvailable().then(available => 
    setwebauthnAvailable(available)
);
```

#### 2. Register this device for WebAuthn

If WebAuthn is available, you can register WebAuthn for the user on button press:

```javascript
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
  user
    .registerWebAuthn() // register WebAuthn
    .then(resp => console.log(resp))
    .catch(err => console.log(err))
}
```
