# WebAuthn.createCredential

Creates a WebAuthn credential and optionally returns its credential-bound PRF output.

## Imports

:::code-group
```ts [Named]
import { WebAuthn } from 'ox'
```

```ts [Entrypoint]
import * as WebAuthn from 'ox/WebAuthn'
```
:::

## Examples

```ts twoslash
import { Secp256k1, WebAuthn } from 'ox'

const credential = await WebAuthn.createCredential({
  name: 'Example',
  prf: true
})
const privateKey = Secp256k1.fromPrf(credential.prf)
```

`prf: true` uses the stable input `ox.webauthn.prf.v1`. Pass `{ input }` to use an application-owned input instead.

When credential creation enables PRF but does not return an output, this function performs a follow-up assertion. The user may be prompted twice.

If PRF evaluation fails after registration, the thrown error retains the created credential on its `credential` property.

:::warning
PRF output is secret application-held key material. Native `credential.raw.toJSON()` output includes extension results, so do not serialize or send the raw credential.

PRF-derived keys are software keys. Code on any origin allowed to use the same RP ID can request the same output after user verification.
:::

## Definition

```ts
function createCredential<options>(
  options: options,
): Promise<createCredential.ReturnType<options>>
```

**Source:** [src/core/WebAuthn.ts](https://github.com/wevm/ox/blob/main/src/core/WebAuthn.ts#L66)

## Parameters

### options

* **Type:** `options`

Credential creation and PRF options.

## Return Type

The credential, with a copied PRF output when requested.

`Promise<createCredential.ReturnType<options>>`
