Skip to main content
MoonKey’s React SDK lets you fully customize authentication to match your app’s brand and user experience. You can implement every authentication flow—including email OTP, OAuth (Google and Apple), and Web3 wallet signatures—with your own UI, while MoonKey manages security and backend logic.
All of MoonKey’s authentication methods can be whitelabeled, allowing you to build completely custom authentication flows without using the default UI components.

Available authentication methods

MoonKey provides headless authentication hooks that give you full control over your UI:

Email OTP

Passwordless email authentication with one-time codes

OAuth

Social login with Google and Apple

Wallet Auth

Web3 authentication with SIWE and SIWS

Email OTP Authentication

To whitelabel MoonKey’s passwordless email flow, use the useLoginWithEmail hook. Call sendCode to send a verification code and loginWithCode to authenticate the user.

Basic usage

With callbacks

You can pass callbacks to handle success and error states:

Flow state tracking

The state object tracks the current status of the authentication flow:
string
The current status of the authentication flow.Possible values:
  • 'initial' - Flow hasn’t started
  • 'sending-code' - Sending OTP to email
  • 'waiting-code-input' - Code sent, waiting for user input
  • 'verifying-code' - Verifying the entered code
  • 'complete' - Authentication successful
  • 'error' - An error occurred
Error | null
Error object if an error occurred, null otherwise.
Learn more about email authentication.

OAuth Authentication

To whitelabel OAuth login with Google and Apple, use the useLoginWithOAuth hook and call initOAuth with your desired provider.

Basic usage

With callbacks

OAuth state tracking

The state object tracks the OAuth flow:
string
The current status of the OAuth flow.Possible values:
  • 'idle' - No OAuth flow in progress
  • 'loading' - OAuth flow in progress
  • 'done' - OAuth authentication successful
  • 'error' - An error occurred
User | null
The authenticated user object after successful OAuth login.
Error | null
Error object if an error occurred.
You must configure OAuth credentials in the MoonKey Dashboard before using OAuth authentication.
Learn more about OAuth authentication.

Complete example

Here’s a complete whitelabel authentication example with both email and OAuth:

Styling example

Best practices

Always show loading indicators during authentication:
Display user-friendly error messages:
Handle navigation and UI updates in callbacks:
Use the flow state to show relevant UI:
Prevent users from modifying inputs during operations:
Check the ready state before rendering auth UI:

Advanced patterns

Multi-step forms

Build multi-step authentication flows:

Conditional authentication

Show different auth methods based on user type:

Prefilled email

Pre-populate email for invited users:

TypeScript types

For TypeScript users, here are the relevant types:

Troubleshooting

If users don’t receive the verification code:
  • Check spam/junk folders
  • Verify the email address is correct
  • Wait a few moments before resending
  • Check your email configuration in the MoonKey Dashboard
If OAuth redirects fail:
  • Verify redirect URLs in the MoonKey Dashboard
  • Check that OAuth credentials are configured
  • Ensure your domain is whitelisted
  • Test in an incognito window to rule out browser issues
If the state doesn’t update correctly:
  • Ensure you’re using the latest SDK version
  • Check that callbacks are properly defined
  • Verify the SDK is initialized correctly
  • Look for console errors