Skip to main content
authenticate() starts the SocketFi authentication flow by opening a hosted popup where the user signs in or registers using a passkey. The method returns a Promise<Session> that resolves once the user has completed authentication and SocketFi has loaded or created their embedded Stellar wallet. The resolved Session contains the user’s profile and a signed access token you can forward to your backend for server-side verification.

Method signature

Parameters

authenticate() takes no parameters. All configuration — including branding, network, and callbacks — is set when you construct the SocketFi instance.

Return value

authenticate() returns Promise<Session>.
UserProfile
required
The authenticated user’s profile.
string
required
A signed JWT issued by SocketFi for this session. Forward this token to your backend in the Authorization: Bearer header. Your server verifies it with verifyAuth() from @socketfi/server. The token encodes the user ID and wallet address and is cryptographically signed — never decode it client-side and trust the contents without server verification.

What happens during authentication

When you call authenticate(), the SDK opens a SocketFi-hosted popup window that guides the user through the following steps:
If the user already has a SocketFi account, their existing wallet is loaded. If this is their first time, a new Stellar smart wallet is created automatically and secured by their passkey.

Usage example

React button integration

Storing the access token

After authentication, store the socketfiAccessToken somewhere your application can access it for subsequent API calls. Common patterns include React state, a context provider, or a lightweight store like Zustand:
Always call authenticate() from a direct user gesture — such as a button’s onClick handler. Browsers block popups that are opened programmatically without a user interaction. If the popup is blocked, the SDK surfaces a POPUP_BLOCKED error. See the Errors reference for handling details.

Error handling