> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# useDeletePasskey

> [card] Recommended: JavaScript SDK with React Hooks
>
> For new React apps, we recommend the JavaScript SDK with React Hooks (`@dynamic-labs-sdk/react-hooks`) instead of the legacy React SDK documented here. The JS SDK comes with many benefits such as a much smaller bundle size and other optimizations. Use the [React quickstart (JavaScript SDK)](https://docs.dynamic.xyz/docs/javascript/reference/react-quickstart.md) to get started.

### Summary

This hook provides a way for developers to delete a passkey for an authenticated user.

The hook needs to be initialized within a child of [DynamicContextProvider](https://docs.dynamic.xyz/docs/react/reference/providers/dynamiccontextprovider.md).

> [!NOTE]
>
> If passkey MFA is enabled, the user will need to authenticate with MFA before deleting a passkey.

### Usage

Available methods:

* `deletePasskey`: Delete a passkey for the authenticated user.

### Usage

```TypeScript theme={"system"}
import { useDeletePasskey } from '@dynamic-labs/sdk-react-core';

const App = () => {
  const deletePasskey = useDeletePasskey();

  return (
    <button
      onClick={() => deletePasskey('passkeyId')}
    >
      Delete Passkey
    </button>
  );
};
```

#### Example with MFA

See [action-based MFA](https://docs.dynamic.xyz/docs/react/authentication-methods/mfa/overview.md#implementation-2) for more information on completing the MFA flow. This example uses the [usePromptMfaAuth](https://docs.dynamic.xyz/docs/react/reference/hooks/login-user-management/usepromptmfa.md) hook to prompt the user to authenticate with MFA via the Dynamic UI.

```TypeScript theme={"system"}
import { useDeletePasskey, usePromptMfaAuth } from '@dynamic-labs/sdk-react-core';

const App = () => {
  const promptMfaAuth = usePromptMfaAuth();
  const deletePasskey = useDeletePasskey();

  const handleDeletePasskey = async () => {
    try {
      await promptMfaAuth({
        createMfaToken: true,
      });
      await deletePasskey('passkeyId');
    } catch (error) {
      console.error('Failed to delete passkey:', error);
    }
  };

  return (
    <button
      onClick={handleDeletePasskey}
    >
      Delete Passkey
    </button>
  );
};
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.