> For the complete documentation index, see [llms.txt](https://docs.cotter.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cotter.app/sdk-reference/web/sign-in-with-webauthn/register-webauthn-for-a-logged-in-user.md).

# 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))
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.cotter.app/sdk-reference/web/sign-in-with-webauthn/register-webauthn-for-a-logged-in-user.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
