@turnkey/sdk-react
The@turnkey/sdk-react package simplifies the integration of the Turnkey API into React-based applications. It builds on top of the @turnkey/sdk-browser package, enabling developers to implement authentication and wallet functionalities using React components.
Overview
- Authentication: Supports email, passkey, phone, and social logins.
- Wallet Operations: Import and export wallets securely.
- Client Utilities: Includes
passkeyClient,authIframeClient, and more. - Components: Abstracts auth, session, import and export logic away from the developer and provides simple, easy to use plug-and-play components
- Customization: Theming options for your components to align with your application’s design
@turnkey/sdk-react when building Next/React applications that interact with the Turnkey API.
Installation
Install the package using npm or Yarn:Initialization
Set up theTurnkeyProvider in your application entry point (e.g., App.tsx):
Using the React SDK
In components nested under theTurnkeyProvider, you can access Turnkey utilities using the useTurnkey hook:
Components
All components require Next.js 13+ with the /app directory structure to leverage server actions. Before using components be sure to Import Turnkey’s default styles in yourlayout.tsx or equivalent entry point:
Authentication
TheAuth component provides a complete authentication solution with support for various login methods.
Example
Wallet Import and Export
Import Wallet Example
Export Wallet Example
Theming with TurnkeyThemeProvider
Customize Turnkey components using CSS variables with the TurnkeyThemeProvider.