Custom UI for Authentication
While Account Kit provides pre-built UI components for authentication, you may want to create your own custom UI to match your application’s design system. This section covers how to implement custom authentication flows using Account Kit hooks.
Tailwind CSS is a required dependency for using Alchemy Account Kit UI components. However, Alchemy Account Kit hooks function independently and do not require Tailwind.
Available Authentication Methods
Account Kit supports several authentication methods that you can implement with custom UI. Each method has its own dedicated page with detailed implementation instructions, code examples, and specific parameters for the authentication hooks:
- Email OTP - One-time password sent via email
- Email Magic Link - Authentication links sent via email
- Social Login - Authentication with providers like Google and Facebook
- Custom Social Providers - Add custom OAuth providers via Auth0
- Passkey Signup - Create accounts with passkeys
- Passkey Login - Authenticate with existing passkeys
- Multi-Factor Authentication - Add an additional verification layer after initial login using an authenticator app
Visit each method’s dedicated page for specific implementation details,
including the exact parameters to use with the useAuthenticate
hook for that
authentication method.
Core Hooks for Custom UI
The following section provides an overview of the main hooks you’ll use when implementing custom authentication UI. These hooks are the foundation for all authentication methods, but their specific usage and parameters vary depending on the authentication method you choose.
useAuthenticate
The useAuthenticate
hook is the foundation for all authentication methods. It provides the authenticate
function that handles the authentication process.
If MFA is required (e.g., the user has added an authenticator app), the authenticate function will throw an MfaRequiredError or request a multiFactorCode. See the MFA docs for a detailed example of handling TOTP codes.
useUser
The useUser
hook returns the current user information from either an External Owned Account (EOA) or from a Smart Contract Account (SCA). This is the best way to check if a user is logged in regardless of account type.
useAccount
The useAccount
hook retrieves the smart contract account instance for the authenticated user. It’s primarily used to get the smart contract account address and interact with the account.
This hook:
- Returns a smart contract account instance (
account
) when the user is logged in - Provides the smart contract account address, not the signer address
- Returns
undefined
for bothaccount
andaddress
when the user is not logged in - Includes an
isLoadingAccount
flag to handle loading states
Note: If you just need to check if a user is logged in (regardless of account type), consider using useUser
instead.
Getting Started
To implement custom authentication UI:
- Choose an authentication method from the list above and visit its dedicated page
- Follow the method-specific implementation guidelines on that page
- Use the core hooks described above following the method-specific parameters
- Implement the UI components for your chosen authentication flow
- Handle success and error states appropriately
Each authentication method page provides detailed code examples tailored to that specific method, showing exactly how to configure the hooks and implement the entire authentication flow.