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.
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
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 for more information on completing the MFA flow. This example uses the usePromptMfaAuth hook to prompt the user to authenticate with MFA via the Dynamic UI.
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>
);
};