authenticate() and receive a session — but the mechanics are different. Instead of a popup, the SDK opens a hosted browser session using expo-web-browser. After the user completes passkey sign-in or registration, SocketFi deep-links back to your app and the Promise resolves with the session.
How authentication works
1
authenticate() opens the hosted browser
The SDK calls
WebBrowser.openAuthSessionAsync() under the hood, launching the SocketFi authentication screen inside an in-app browser.2
User authenticates with a passkey
New users register a device passkey. Returning users verify their existing passkey. The SDK handles both automatically.
3
Wallet resolved or created
For returning users, the associated Stellar smart wallet is resolved. For new users, a new embedded smart wallet is created and activated.
4
Deep link returns the user to your app
After the flow completes, SocketFi redirects the browser to
yourscheme://socketfi/auth/success and the in-app browser closes.5
Session returned
The
authenticate() Promise resolves with the Session object containing the user profile and access token.The Session object
userProfile for identifying the user in your UI and socketfiAccessToken for authenticated SDK calls. Do not store sensitive wallet internals on the client.
Persisting sessions with SecureStore
Because React Native apps can be killed and relaunched, you should persist the session token to device storage so users don’t need to re-authenticate every time they open the app. Useexpo-secure-store for encrypted storage on both iOS and Android.
lib/session.ts
AuthProvider + useSocketFiAuth hook
The pattern below gives every component in your app access to the current session, alogin function, and a logout function. It also restores the persisted session automatically when the app launches.
lib/AuthProvider.tsx
Wiring AuthProvider into your app
Wrap your root component withAuthProvider so the hook is available everywhere:
App.tsx
Login button example
components/LoginButton.tsx
Handling session restoration on app launch
TheisLoading flag from the context tells you whether the persisted session check is still in progress. Use it to show a splash screen or loading indicator before rendering authenticated content:
navigation/RootNavigator.tsx
Error handling
Wrap allauthenticate() calls in try/catch and handle the codes your users are most likely to see: