Privy provides user authentication and wallet management solutions for web3 applications. By integrating Privy with Base Account, you can offer users a smooth onboarding experience with embedded wallets and Base Account functionality.
Create your Privy configuration with Base Account support:
Copy
Ask AI
// app/layout.tsx or pages/_app.tsx'use client'import { PrivyProvider } from '@privy-io/react-auth'import { WagmiProvider } from '@privy-io/wagmi-connector'import { base } from 'viem/chains'import { http } from 'viem'import { baseAccount } from 'wagmi/connectors'const privyConfig = { embeddedWallets: { createOnLogin: 'users-without-wallets' as const, requireUserPasswordOnCreate: false, }, loginMethods: ['email', 'wallet', 'google'], appearance: { theme: 'light' as const, accentColor: '#0052FF', // Base blue logo: 'https://your-logo-url.com/logo.png', walletList: [ 'base_account', 'coinbase_wallet', // It is recommended to support coinbase_wallet for any users still using the legacy EOA ], }, supportedChains: [base],}const wagmiConfig = { chains: [base], transports: { [base.id]: http(), }, connectors: [ baseAccount({ appName: 'Your App Name', }) ],}export default function App({ children }: { children: React.ReactNode }) { return ( <PrivyProvider appId={process.env.NEXT_PUBLIC_PRIVY_APP_ID!} config={privyConfig} > <WagmiProvider config={wagmiConfig}> {children} </WagmiProvider> </PrivyProvider> )}
To have Sign in with Base as a top level sign in option in the login modal, modify your privyConfig to include base_account in the loginMethodsAndOrder field.
Copy
Ask AI
const privyConfig = { embeddedWallets: { createOnLogin: 'users-without-wallets' as const, requireUserPasswordOnCreate: false, }, loginMethodsAndOrder: { primary: ['base_account','email', 'wallet'], }, appearance: { theme: 'light' as const, accentColor: '#0052FF' as const, // Base blue walletList: ['base_account', 'coinbase_wallet'], }, supportedChains: [base],};