useEmbeddedWallet
Hook to connect EmbeddedWallet
which allows users to login via Email or social logins
The embeddedWallet()
should be added to ThirdwebProvider
's supportedWallets
prop to enable auto-connection on page load
import { useEmbeddedWallet } from "@thirdweb-dev/react"; function App() { const { connect } = useEmbeddedWallet(); const handleLogin = async () => { await connect({ strategy: "google", }); }; return <button onClick={handleLogin}> Sign in with Google </button>;}
import { useEmbeddedWallet } from "@thirdweb-dev/react"; function App() { const { connect, sendVerificationEmail } = useEmbeddedWallet(); const sendVerificationCode = async (email: string) => { // send email verification code await sendVerificationEmail({ email }); }; const handleLogin = async ( email: string, verificationCode: string, ) => { // verify email and connect await connect({ strategy: "email_verification", email, verificationCode, }); }; return <div> ... </div>;}
// email verificationtype EmailVerificationAuthParams = { strategy: "email_verification"; email: string; verificationCode: string; recoveryCode?: string;}; export type EmbeddedWalletOauthStrategy = | "google" | "apple" | "facebook"; type OauthAuthParams = { strategy: EmbeddedWalletOauthStrategy; openedWindow?: Window; closeOpenedWindow?: (window: Window) => void;}; // bring your own authenticationtype JwtAuthParams = { strategy: "jwt"; jwt: string; encryptionKey?: string;}; // open iframe to send and input the verification code onlytype IframeOtpAuthParams = { strategy: "iframe_email_verification"; email: string;}; // open iframe to enter email and verification codetype IframeAuthParams = { strategy: "iframe";};
function useEmbeddedWallet(): { sendVerificationEmail: (__namedParameters: { email: string;};
let returnType: { sendVerificationEmail: (__namedParameters: { email: string;};
Social Login