This guide walks you through integrating Turnkey into a React application usingDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/tkhq/sdk/llms.txt
Use this file to discover all available pages before exploring further.
@turnkey/react-wallet-kit. It is the recommended path for most web applications.
Prerequisites
- Node.js 18 or later
- A Turnkey account with an organization created (sign up at app.turnkey.com)
- Your Organization ID from the Turnkey dashboard
- An Auth Proxy Config ID from the Turnkey dashboard
React quickstart
Install @turnkey/react-wallet-kit
Add the package to your project using your preferred package manager.If you are starting from scratch, first create a Next.js app:
terminal
Set up environment variables
Add your Turnkey credentials to your environment file. In a Next.js project, use Both values are available in the Turnkey dashboard.
.env.local..env.local
Wrap your app with TurnkeyProvider
With Next.js App Router, keep You can also add an Then import and use your
app/layout.tsx as a server component and create a separate app/providers.tsx client wrapper. This is required to pass callbacks (such as onError), which must be defined in a client component.app/providers.tsx
onError callback to handle errors in one place:app/providers.tsx
Providers wrapper in app/layout.tsx. Import the SDK styles here too.app/layout.tsx
Keeping
layout.tsx as a server component maintains optimal rendering and avoids making your entire app client-side. Centralizing Turnkey setup in providers.tsx keeps configuration, styles, and callbacks in one place.Add a login button
The easiest way to handle authentication is with the The
handleLogin function from the useTurnkey hook. Calling it opens a modal with all authentication methods you have enabled in your Turnkey dashboard.components/LoginButton.tsx
handleLogin function supports passkeys, email OTP, SMS OTP, and OAuth providers (Google, Apple, Facebook, X, Discord) — whichever you have enabled in your Auth Proxy Config.Server-side quickstart
To interact with the Turnkey API from a Node.js backend, use@turnkey/sdk-server.
server.js
Next steps
Core concepts
Learn about organizations, sub-organizations, wallets, stampers, and how Turnkey’s auth model works.
@turnkey/react-wallet-kit
Full reference for the React Wallet Kit package, including all config options and hook methods.
Authentication guide
Deep dive into authentication flows: passkeys, OTP, OAuth, and wallet-based login.
Blockchain signers
Connect a Turnkey wallet to ethers.js, viem, Solana, or CosmJS.