Skip to main content
The SignInWithBaseButton is a ready-to-use React component that provides a seamless authentication experience using Base Account. It handles the entire sign-in flow including wallet connection, message signing, and user authentication.
Please Follow the brand guidelinesIf you intend on using the SignInWithBaseButton, please follow the Brand Guidelines to ensure consistency across your application.

Installation

Basic Usage

Props

Styling Props

align
'left' | 'center' | 'right'
Button alignment within its container (default: ‘left’)
variant
'solid' | 'transparent'
Button variant style (default: ‘solid’)
colorScheme
'light' | 'dark' | 'system'
Color scheme for the button appearance (default: ‘system’)
size
'small' | 'medium' | 'large'
Button size (default: ‘medium’)
disabled
boolean
Whether the button is disabled (default: false)

Event Handlers

onClick
function
Callback function called when the button is clicked
onSignInResult
function
Callback function called when authentication completes (success or failure)

Styling Options

Alignment

Variants

Color Schemes

Sizes

Authentication Flow Integration

Complete Authentication Example

SIWE Integration

Custom Button States

Loading State

Error State Handling

Integration with Authentication Providers

NextAuth.js Integration

Below is an example of how to configure NextAuth to use Base Account as a credentials provider, so you can use Base Account in your Next.js application.
NextAuth.js IntegrationNext.js is a popular React framework, and NextAuth.js is an authentication library for Next.js. It offers session management and providers.
pages/api/auth/[...nextauth].js
page.tsx

TypeScript Support

Best Practices

  1. Handle Loading States: Disable the button during authentication to prevent multiple attempts
  2. Error Handling: Provide clear error messages for different failure scenarios
  3. Security: Always verify signatures on your backend before trusting authentication
  4. User Experience: Show clear feedback during the authentication process
  5. Accessibility: The button includes proper ARIA labels and keyboard navigation
  6. Testing: Test with different wallet states (connected, disconnected, etc.)
The SignInWithBaseButton provides a complete, production-ready authentication solution that handles all the complexity of wallet-based authentication while providing a familiar user experience.