Tis hook provides functionality for creating a new passkey signer in the context of a smart account. It handles the creation process and manages loading and error states.
Copy import { useCreateNewSigner } from "@cometh/connect-react-hooks";
const MyComponent = () => {
const { createSigner, isLoading, error, data } = useCreateNewSigner('your-api-key', 'https://api.example.com');
const handleCreateSigner = async () => {
try {
const newSigner = await createSigner({
smartAccountAddress: '0x1234...', // Replace with actual address
passKeyName: 'MyNewPasskey'
});
console.log('New signer created:', newSigner);
} catch (err) {
console.error('Error creating signer:', err);
}
};
return (
<div>
<button onClick={handleCreateSigner} disabled={isLoading}>
Create New Signer
</button>
{isLoading && <p>Creating signer...</p>}
{error && <p>Error: {error.message}</p>}
{data && <p>Signer created successfully!</p>}
</div>
);
};