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 callauthenticate(), the SDK opens a SocketFi-hosted popup window that guides the user through the following steps:
Usage example
React button integration
Storing the access token
After authentication, store thesocketfiAccessToken somewhere your application can access it for subsequent API calls. Common patterns include React state, a context provider, or a lightweight store like Zustand: