Email Login
Web3Modal SDK enables passwordless Web3 onboarding (no seed phrases) and authentication. It offers blazing-fast, hardware-secured, passwordless login, Web3 onboarding, and access to over 20 blockchains with a few lines of code — even if you have an existing auth solution.
caution
Email Login is currently in Beta.
- Wagmi
- Ethers
You can start integrating Email Login into Web3Modal SDK using either default or custom mode.
- Default
- Custom
'use client'
import { createWeb3Modal, defaultWagmiConfig } from '@web3modal/wagmi/react'
import { WagmiConfig } from 'wagmi'
import { arbitrum, mainnet } from 'viem/chains'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
// 0. Setup queryClient
const queryClient = new QueryClient()
// 1. Get projectId at https://cloud.walletconnect.com
const projectId = 'YOUR_PROJECT_ID'
// 2. Create wagmiConfig
const metadata = {
name: 'Web3Modal',
description: 'Web3Modal Example',
url: 'https://web3modal.com',
icons: ['https://avatars.githubusercontent.com/u/37784886']
}
const chains = [mainnet, arbitrum]
const wagmiConfig = defaultWagmiConfig({
chains, // required
projectId, // required
metadata, // required
enableWalletConnect: true, // Optional - true by default
enableInjected: true, // Optional - true by default
enableEIP6963: true, // Optional - true by default
enableCoinbase: true, // Optional - true by default
enableEmail: true // Optional - false by default
})
// 3. Create modal
createWeb3Modal({ wagmiConfig, projectId, chains })
export function Web3Modal({ children }) {
return (
<WagmiConfig config={wagmiConfig}>
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
</WagmiConfig>
)
}
'use client'
import type { ReactNode } from 'react'
import { createWeb3Modal } from '@web3modal/wagmi/react'
import { emailConnector } from '@web3modal/wagmi'
import { WagmiProvider, cookieStorage, createStorage, createConfig, http } from 'wagmi'
import { mainnet, sepolia } from 'wagmi/chains'
import { walletConnect, injected, coinbaseWallet } from 'wagmi/connectors'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
// 0. Setup queryClient
const queryClient = new QueryClient()
// 1. Get projectId at https://cloud.walletconnect.com
const projectId = 'YOUR_PROJECT_ID'
// 2. Create wagmiConfig
const metadata = {
name: 'Web3Modal',
description: 'Web3Modal Example',
url: 'https://web3modal.com',
icons: ['https://avatars.githubusercontent.com/u/37784886']
}
const chains = [mainnet, sepolia] as const
export const wagmiConfig = createConfig({
chains,
transports: {
[mainnet.id]: http(),
[sepolia.id]: http()
},
connectors: [
walletConnect({ projectId, metadata, showQrModal: false }),
injected({ shimDisconnect: true }),
coinbaseWallet({
appName: metadata.name,
appLogoUrl: metadata.icons[0]
}),
emailConnector({ chains, options: { projectId } })
],
ssr: true,
storage: createStorage({
storage: cookieStorage
})
})
createWeb3Modal({ wagmiConfig, projectId, chains })
export function Web3Modal({
children,
initialState
}: {
children: ReactNode
initialState?: State
}) {
return (
<WagmiProvider config={wagmiConfig} initialState={initialState}>
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
</WagmiProvider>
)
}
You can start integrating Email Login into Web3Modal SDK using either default or custom mode.
- Default
- Custom
'use client'
import { createWeb3Modal, defaultConfig } from '@web3modal/ethers/react'
// 1. Get projectId at https://cloud.walletconnect.com
const projectId = 'YOUR_PROJECT_ID'
// 2. Set chains
const mainnet = {
chainId: 1,
name: 'Ethereum',
currency: 'ETH',
explorerUrl: 'https://etherscan.io',
rpcUrl: 'https://cloudflare-eth.com'
}
// 3. Create modal
const metadata = {
name: 'My Website',
description: 'My Website description',
url: 'https://mywebsite.com',
icons: ['https://avatars.mywebsite.com/']
}
createWeb3Modal({
ethersConfig: defaultConfig({
metadata,
enableEmail: true
}),
chains: [mainnet],
projectId
})
export function Web3ModalProvider({ children }) {
return children
}
"use client"
import { createWeb3Modal, defaultConfig } from '@web3modal/ethers/react'
// 1. Get projectId at https://cloud.walletconnect.com
const projectId = 'YOUR_PROJECT_ID'
// 2. Set chains
const mainnet = {
chainId: 1,
name: 'Ethereum',
currency: 'ETH',
explorerUrl: 'https://etherscan.io',
rpcUrl: 'https://cloudflare-eth.com'
}
// 3. Create modal
const metadata = {
name: 'My Website',
description: 'My Website description',
url: 'https://mywebsite.com',
icons: ['https://avatars.mywebsite.com/']
}
createWeb3Modal({
ethersConfig: defaultConfig({
metadata,
defaultChainId: 1,
enableEIP6963: true,
enableInjected: true,
enableCoinbase: true,
enableEmail: true
rpcUrl: '...' // used for the Coinbase SDK
}),
chains: [mainnet],
projectId
})
export function Web3Modal({ children }) {
return <WagmiConfig config={wagmiConfig}>{children}</WagmiConfig>;
}
Was this helpful?