Overview
Magic provides passwordless authentication and embedded wallet infrastructure that enables seamless user onboarding. This guide shows you how to integrate Magic signers with Rhinestone smart accounts to create a unified, cross-chain wallet experience. How it works: Magic handles user authentication and provides wallet clients. We use Magic’s authenticated user data to create Rhinestone smart accounts, which enables cross-chain functionality with a single wallet experience.Prerequisites
- A Magic account and API key
- Rhinestone API key
- React/Next.js application setup
Installation
Install the required dependencies:Setup Magic Provider
First, set up the Magic provider in your React application:Create a Magic Integration Hook
Create a custom hook that integrates Magic authentication with Rhinestone accounts. This demonstrates the core pattern: get the wallet client from Magic, then pass it to Rhinestone.Magic provides a direct RPC provider that we convert to a viem wallet client compatible with Rhinestone.
Usage
Basic Authentication Flow
Use the hook to handle Magic authentication and smart account creation:Cross-Chain Transactions
Send transactions using the Magic-connected wallet:Authentication Methods
Magic supports multiple authentication methods:- Email OTP:
magic.auth.loginWithEmailOTP({ email })
- SMS:
magic.auth.loginWithSMS({ phoneNumber })
- Social:
magic.oauth.loginWithRedirect({ provider: 'google' })
- WebAuthn:
magic.webauthn.loginWithWebAuthn({})
Environment Variables
Make sure to set the following environment variables:Complete Example
Here’s a minimal working example that demonstrates the integration:Next Steps
- See it in action: Check out our complete Magic example for a full working app
- Learn more about Magic’s authentication methods
- Explore chain abstraction capabilities
- Check out creating an account for more details