Compatibility
The Wallet Kit widget requires React 18+ and is available for web applications using the JavaScript SDK.Use Cases
- Add a complete login UI to your React app without building custom components
- Support multiple authentication methods (email OTP, OAuth, external wallets) from a single widget
Getting Started
Installation
Usage
Initialize Magic with theWalletKitExtension, then render the MagicWidget component in your app.
JavaScript
Configuration
The widget displays login options based on two sources: Dashboard-configured options — Email OTP and OAuth providers (Google, Apple, GitHub, etc.) are configured in your Magic Dashboard. Enable the authentication methods you want, and they will automatically appear in the widget. Code-configured options — External wallets (MetaMask, Coinbase, etc.) are configured via thewallets prop. Only the wallets you specify will be displayed.
For example, if you enable Email and Google OAuth in your dashboard and pass wallets={['metamask']}, the widget will show all three options: email input, Google sign-in button, and MetaMask.
WalletConnect
If you include'walletconnect' in the wallets prop, the widget uses Reown (formerly WalletConnect) under the hood. A default project ID is included for development, but for production apps you should provide your own to avoid rate limiting:
JavaScript
API Reference
Props
| Prop | Type | Default | Description |
|---|---|---|---|
displayMode | 'inline' | 'modal' | 'inline' | How the widget is displayed. 'inline' renders in document flow, 'modal' shows as an overlay. |
isOpen | boolean | true | Whether the widget is visible. |
onClose | () => void | — | Called when the user closes the widget. |
closeOnSuccess | boolean | false | Automatically close after successful login (shows success screen for 2 seconds first). |
closeOnClickOutside | boolean | false | Close when clicking the backdrop. Only applies in modal mode. |
wallets | Array | [] | External wallets to display: 'metamask', 'coinbase', 'phantom', 'rabby', 'walletconnect'. |
onSuccess | (result: LoginResult) => void | — | Called on successful login. See Login Results for result structure. |
onError | (error: Error) => void | — | Called when login fails. |
onReady | () => void | — | Called when the widget has initialized and applied theme settings. |
Login Results
TheonSuccess callback receives a result object with a method property indicating the authentication type:
result.didToken for backend verification. For OAuth logins, use result.magic.idToken.
Examples
Modal Mode
Use modal mode to display the widget as an overlay:JavaScript
Loading State
The widget fetches configuration from your Magic dashboard before rendering. During this time, it returnsnull. To show a loading indicator, render the widget with isOpen={false} and wait for onReady:
JavaScript
Create the Magic instance outside your component or use
useMemo to prevent recreating it on every render.