Skip to main content
This guide walks through a complete SocketFi integration from scratch. By the time you reach the end, you will have a working React application that authenticates a user with their passkey, loads their embedded smart wallet, reads data from a Soroban contract, and requests a signed transaction — all without your user ever touching a seed phrase or external wallet.
This guide uses @socketfi/react. If you’re building for React Native, swap the import for @socketfi/react-native — the API is identical.
1

Install @socketfi/react

Add the React SDK to your project. If you haven’t already set up your Client ID and environment variables, complete the Installation guide first.
Add your Client ID to your environment file:
2

Initialise the SocketFi client

Create a single shared SocketFi instance. Export it from a dedicated module so every part of your application uses the same client without re-initialising.
You can optionally pass a brand object to customise the authentication popup with your app’s name and primary colour:
3

Authenticate a user

Call socketfi.authenticate() from a user interaction (a button click). SocketFi opens a secure hosted authentication flow where the user can sign in with an existing passkey or register a new one using Face ID, Touch ID, or Windows Hello.
A successful call returns a session object:
The socketfiAccessToken identifies the authenticated user. Store it (for example in React Context or localStorage) to use in subsequent API calls.
Always trigger authenticate() from a button click or equivalent user interaction. Calling it programmatically on page load will be blocked by browser popup policies.
4

Request a transaction

Once the user is authenticated, call requestTransaction() to propose an on-chain operation. SocketFi presents a hosted approval UI showing exactly what the transaction does before the user confirms and signs.
A confirmed transaction returns:
Wrap every requestTransaction() call in a try/catch — users can decline the approval, and network errors can occur.

Read contract state

Read-only contract calls do not require user approval and execute immediately. Use readContract() to query any Soroban contract — for example to fetch a wallet balance before proposing a transfer.
Because readContract() doesn’t write to the chain, it’s safe to call at any point after initialisation — you don’t need a fully authenticated session for read-only data.

Verify authentication on your backend

Never rely on client-side state alone to gate access to protected resources. Always send the socketfiAccessToken to your API and verify it with the Server SDK. Frontend — attach the token to your request
Backend — verify the token with verifyAuth()
verifyAuth() returns both the verified user identity and their associated wallet address, giving you a trustworthy, server-side source of truth for the current user.

Complete working example

Here’s a minimal but complete React component that ties every step together — login, transaction, and contract read.

What to do next

You’ve now covered the full integration surface: installation, authentication, contract reads, transactions, and backend verification. From here: