Skip to main content
Authentication in the React Native SDK follows the same API as the React SDK — you call 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

Store 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. Use expo-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, a login 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 with AuthProvider so the hook is available everywhere:
App.tsx

Login button example

components/LoginButton.tsx

Handling session restoration on app launch

The isLoading 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 all authenticate() calls in try/catch and handle the codes your users are most likely to see:

Error codes reference

If you see DEEP_LINK_NOT_CONFIGURED errors during testing, make sure you are running a development build (npx expo run:ios / npx expo run:android) rather than Expo Go. Expo Go uses its own URL scheme and cannot intercept your custom scheme.