Skip to content

SDK Reference

ZeroDev Wallet React SDK

This page documents the public React SDK exports from @zerodev/wallet-react. Use the guide pages for complete workflows, and use this page when you need exact parameters and return values.

Import

import {
  OAUTH_PROVIDERS,
  createZeroDevWalletStore,
  generateOAuthNonce,
  getZeroDevConnector,
  getZeroDevStore,
  getZeroDevWallet,
  useAuthenticateOAuth,
  useAuthenticators,
  useExportPrivateKey,
  useExportWallet,
  useLoginPasskey,
  useRefreshSession,
  useRegisterPasskey,
  useSendMagicLink,
  useSendOTP,
  useVerifyMagicLink,
  useVerifyOTP,
  verifyGoogleLoginUrl,
  zeroDevWallet,
  type GetOAuthSessionIdFn,
  type OAuthProvider,
  type WalletMode,
  type ZeroDevProvider,
  type ZeroDevWalletConnectorParams,
  type ZeroDevWalletState,
} from "@zerodev/wallet-react";

Connector

zeroDevWallet(params)

Creates the Wagmi connector used by createConfig.

import { zeroDevWallet } from "@zerodev/wallet-react";
 
const connector = zeroDevWallet({
  projectId: "<your-project-id>",
  aaUrl: "<your-chain-specific-zerodev-rpc-url>",
  chains: [arbitrumSepolia],
  mode: "7702",
});

Parameters

NameTypeRequiredDescription
projectIdstringYesZeroDev project ID from the dashboard.
chainsreadonly Chain[]YesViem/Wagmi chain objects enabled for the project. The first chain is used as the default active chain.
aaUrlstringNoBundler/paymaster RPC URL. Required for 7702 and 4337 flows that send UserOperations or use gas sponsorship. If omitted, the connector derives the AA URL from projectId and chain ID.
mode"7702" | "4337"NoWallet mode. Defaults to "7702".
rpIdstringNoRelying party ID for passkeys. For web apps, use the hostname that owns the passkey, for example localhost or app.example.com.
organizationIdstringNoExisting Turnkey organization ID, when you need to bind the wallet to a known organization. Most apps omit this.
proxyBaseUrlstringNoCustom backend/proxy base URL for wallet services. Most apps use the default ZeroDev service.
sessionStorageStorageAdapterNoStorage adapter used by the wallet core session layer.
persistStorageStateStorage<void>NoZustand persistence storage for React connector state. The default persists session data under zerodev-wallet.
apiKeyStamperApiKeyStamper | Promise<ApiKeyStamper>NoAdvanced stamper override. Usually used by native or custom key management flows.
passkeyStamperPasskeyStamper | Promise<PasskeyStamper>NoAdvanced passkey stamper override.
fetchOptionsCreateTransportOptions["fetchOptions"]NoForwarded to Turnkey and AA transports. Web apps usually do not need this because browsers ignore custom Origin overrides.
autoRefreshSessionbooleanNoEnables automatic session refresh behavior in the provider layer.
sessionWarningThresholdnumberNoMilliseconds before expiry when the session should be considered expiring.
autoInitializeboolean | () => booleanNoControls whether connector setup initializes on mount. Defaults to true in browser and React Native environments. If false, initialization happens lazily on connect/provider/store access.

Returns

CreateConnectorFn, suitable for Wagmi createConfig({ connectors: [...] }).

Account modes

ModeAddress shown to WagmiTransaction pathWhen to use
7702User wallet addressEIP-7702 Kernel UserOperationsRecommended default. Users keep a familiar wallet address while apps can use account abstraction features such as gas sponsorship.
4337Counterfactual Kernel smart account addressERC-4337 UserOperationsUse when you explicitly want a 4337 smart account address.

Hook options

All authentication, session, and export hooks are TanStack Query hooks. Mutation hooks return UseMutationResult, so you can use mutate, mutateAsync, isPending, error, data, and reset.

Most hooks accept an optional config field when you need to pass a specific Wagmi config instead of using the nearest WagmiProvider.

const { mutateAsync, isPending, error } = useRegisterPasskey({
  mutation: {
    onSuccess: () => console.log("signed in"),
  },
});
OptionTypeDescription
configConfigOptional Wagmi config override.
mutationUseMutationOptionsMutation options for auth, session, and export hooks. Not available on query hooks.
queryUseQueryOptionsQuery options for useAuthenticators.

Passkeys

useRegisterPasskey(options?)

Registers a new passkey and authenticates the user. On success, the hook stores the session, derives the wallet account, and connects the ZeroDev connector in Wagmi.

Mutation variables

NameTypeRequiredDescription
connectorConnectorNoZeroDev Wagmi connector override. Defaults to the connector with ID zerodev-wallet in the active Wagmi config.

Returns

UseMutationResult<void, Error, void | { connector?: Connector }>

const registerPasskey = useRegisterPasskey();
 
<button onClick={() => registerPasskey.mutateAsync()}>
  Register passkey
</button>;

useLoginPasskey(options?)

Authenticates with an existing passkey. On success, it stores the session, derives the wallet account, and connects the ZeroDev connector in Wagmi.

Mutation variables

NameTypeRequiredDescription
connectorConnectorNoZeroDev Wagmi connector override.

Returns

UseMutationResult<void, Error, void | { connector?: Connector }>

const loginPasskey = useLoginPasskey();
 
<button onClick={() => loginPasskey.mutateAsync()}>
  Login with passkey
</button>;

Email OTP

useSendOTP(options?)

Sends an email OTP code.

Mutation variables

NameTypeRequiredDescription
emailstringYesUser email address.
emailCustomization{ magicLinkTemplate?: string }NoOptional email template customization.
connectorConnectorNoZeroDev Wagmi connector override.

Returns

UseMutationResult<{ otpId: string; otpEncryptionTargetBundle: string }, Error, SendOTPVariables>

Store both returned values. useVerifyOTP needs the matching otpId and otpEncryptionTargetBundle.

const sendOTP = useSendOTP();
const verifyOTP = useVerifyOTP();
 
const sent = await sendOTP.mutateAsync({ email });
 
await verifyOTP.mutateAsync({
  otpId: sent.otpId,
  otpEncryptionTargetBundle: sent.otpEncryptionTargetBundle,
  code,
});

useVerifyOTP(options?)

Verifies an OTP code and authenticates the user. On success, it stores the session, derives the wallet account, and connects the ZeroDev connector in Wagmi.

Mutation variables

NameTypeRequiredDescription
otpIdstringYesOTP ID returned by useSendOTP.
otpEncryptionTargetBundlestringYesEncryption target bundle returned by the matching useSendOTP call.
codestringYesCode entered by the user.
connectorConnectorNoZeroDev Wagmi connector override.

Returns

UseMutationResult<void, Error, VerifyOTPVariables>

Magic links

useSendMagicLink(options?)

Sends a magic link email.

Mutation variables

NameTypeRequiredDescription
emailstringYesUser email address.
redirectURLstringYesURL the email link should return to after the user opens it. The URL must be allowlisted for the project.
connectorConnectorNoZeroDev Wagmi connector override.

Returns

UseMutationResult<{ otpId: string; otpEncryptionTargetBundle: string }, Error, SendMagicLinkVariables>

Store both returned values. useVerifyMagicLink needs the matching otpId and otpEncryptionTargetBundle.

const sendMagicLink = useSendMagicLink();
 
const sent = await sendMagicLink.mutateAsync({
  email,
  redirectURL: `${window.location.origin}/wallets/callback`,
});

useVerifyMagicLink(options?)

Verifies the magic link code and authenticates the user.

Mutation variables

NameTypeRequiredDescription
otpIdstringYesOTP ID returned by useSendMagicLink.
otpEncryptionTargetBundlestringYesEncryption target bundle returned by the matching useSendMagicLink call.
codestringYesCode from the magic link redirect.
connectorConnectorNoZeroDev Wagmi connector override.

Returns

UseMutationResult<void, Error, VerifyMagicLinkVariables>

OAuth

useAuthenticateOAuth(options?)

Starts the web OAuth flow using a popup and authenticates the user after the popup returns a session ID. The web hook uses window.location.href as the redirect URI and window.location.origin for popup polling.

Options

NameTypeRequiredDescription
timeoutMsnumberNoPopup polling timeout in milliseconds. Defaults to 5 minutes.
configConfigNoOptional Wagmi config override.
mutationUseMutationOptionsNoTanStack mutation options.

Mutation variables

NameTypeRequiredDescription
providerOAuthProviderYesOAuth provider. Use OAUTH_PROVIDERS.GOOGLE for Google.

Returns

UseMutationResult<void, Error, { provider: OAuthProvider }>

const google = useAuthenticateOAuth();
 
<button
  onClick={() => google.mutateAsync({ provider: OAUTH_PROVIDERS.GOOGLE })}
>
  Continue with Google
</button>;

OAUTH_PROVIDERS

Supported OAuth provider constants.

NameValue
OAUTH_PROVIDERS.GOOGLE"google"

OAuthProvider

Type union of supported OAuth provider values. Currently "google".

GetOAuthSessionIdFn

Function type for custom OAuth adapters.

type GetOAuthSessionIdFn = (params: {
  oauthUrl: string;
  provider: OAuthProvider;
}) => Promise<string>;

The web hook supplies this automatically. Custom platform flows use this shape to open the OAuth URL and return a session ID.

Sessions

useRefreshSession(options?)

Refreshes the current authenticated session and updates connector state.

Mutation variables

NameTypeRequiredDescription
connectorConnectorNoZeroDev Wagmi connector override.

Returns

UseMutationResult<unknown, Error, { connector?: Connector }>

Throws when there is no active session to refresh.

const refreshSession = useRefreshSession();
 
await refreshSession.mutateAsync({});

Authenticators

useAuthenticators(options?)

Reads authenticators associated with the current user in the connected project/sub-organization. The result can include OAuth authenticators, passkeys, email contacts, and API keys.

Options

NameTypeRequiredDescription
configConfigNoOptional Wagmi config override.
queryUseQueryOptionsNoTanStack query options, excluding queryKey and queryFn.

Returns

UseQueryResult<GetAuthenticatorsReturnType, Error>

const authenticators = useAuthenticators({
  query: { enabled: isConnected },
});

Wallet export

useExportWallet(options?)

Renders the secure Turnkey export iframe into a container element and injects the wallet export bundle.

Mutation variables

NameTypeRequiredDescription
iframeContainerIdstringYesDOM element ID where the export iframe should be mounted.
iframeStylesRecord<string, string>NoCSS styles passed to the iframe stamper.
connectorConnectorNoZeroDev Wagmi connector override.

Returns

UseMutationResult<void, Error, ExportWalletVariables>

const exportWallet = useExportWallet();
 
await exportWallet.mutateAsync({
  iframeContainerId: "export-wallet",
  iframeStyles: {
    width: "100%",
    height: "260px",
  },
});

useExportPrivateKey(options?)

Renders the secure Turnkey export iframe into a container element and injects a private key export bundle.

Mutation variables

NameTypeRequiredDescription
iframeContainerIdstringYesDOM element ID where the export iframe should be mounted.
iframeStylesRecord<string, string>NoCSS styles passed to the iframe stamper.
addressstringNoSpecific wallet address/key to export.
keyFormat"Hexadecimal" | "Solana"NoExport format. Defaults to "Hexadecimal".
connectorConnectorNoZeroDev Wagmi connector override.

Returns

UseMutationResult<void, Error, ExportPrivateKeyVariables>

const exportPrivateKey = useExportPrivateKey();
 
await exportPrivateKey.mutateAsync({
  iframeContainerId: "export-private-key",
  keyFormat: "Hexadecimal",
});

Store and connector helpers

These helpers are lower-level escape hatches. Most apps should use Wagmi hooks and ZeroDev auth hooks instead.

getZeroDevConnector(config)

Finds the ZeroDev connector in a Wagmi config.

ParameterTypeDescription
configConfigWagmi config containing a zerodev-wallet connector.

Returns the ZeroDev connector, including rpId and getStore(). Throws if the connector is not found.

getZeroDevStore(connector)

Gets the Zustand store associated with a ZeroDev connector.

ParameterTypeDescription
connectorConnectorZeroDev connector returned by zeroDevWallet.

Returns Promise<ReturnType<typeof createZeroDevWalletStore>>.

getZeroDevWallet(store)

Reads the initialized wallet SDK instance from the ZeroDev store.

ParameterTypeDescription
storeReturnType<typeof createZeroDevWalletStore>ZeroDev wallet store.

Returns ZeroDevWalletSDK. Throws "Wallet not initialized" if connector setup has not completed.

createZeroDevWalletStore(options?)

Creates the internal Zustand store used by the connector.

ParameterTypeDescription
options.storageStateStorage<void>Optional custom persistence storage.

The store persists only session and activeChainId under the zerodev-wallet key.

OAuth utilities

generateOAuthNonce(publicKey)

Computes the nonce expected in a Google OAuth URL for a wallet public key.

ParameterTypeDescription
publicKeystringWallet public key, with or without 0x prefix.

Returns a lowercase hex SHA-256 hash string without 0x.

verifyGoogleLoginUrl(loginUrl, publicKey)

Verifies that a Google OAuth URL is valid for the wallet public key.

ParameterTypeDescription
loginUrlstringOAuth URL returned by the backend.
publicKeystringWallet public key used to verify the nonce.

Returns void. Throws if the URL is malformed, the host is not accounts.google.com, the nonce is missing, or the nonce does not match generateOAuthNonce(publicKey).

Types

WalletMode

type WalletMode = "4337" | "7702";

ZeroDevWalletConnectorParams

Connector parameter type for zeroDevWallet. It matches the connector parameters above.

ZeroDevProvider

ZeroDev EIP-1193 provider type returned by the connector's getProvider() method.

ZeroDevWalletState

Zustand store state type used internally by the connector.

Important fields include:

FieldTypeDescription
walletZeroDevWalletSDK | nullCore wallet SDK instance.
sessionZeroDevWalletSession | nullActive wallet session.
activeChainIdnumber | nullActive chain ID.
kernelAccountsMap<number, SmartAccount>Per-chain Kernel accounts for 7702 and 4337 modes.
kernelClientsMap<number, KernelAccountClient>Per-chain Kernel clients for account abstraction transactions.
walletClientsMap<number, WalletClient>Per-chain Viem wallet clients used internally by the connector.
isExpiringbooleanWhether the session is near expiry.

Related guides