SocketFi class is the single entry point for all client-side SDK operations. Instantiating it with your application’s clientId and desired configuration gives you an object from which you can authenticate users, request transactions, and read smart contract data. You create the instance once, configure it with your branding and network settings, and reuse it everywhere in your application.
Constructor signature
Configuration parameters
string
required
Your application’s unique SocketFi identifier, obtained from the Developer Portal. This value scopes all authentication and transaction requests to your specific application.
'TESTNET' | 'MAINNET'
default:"'TESTNET'"
The Stellar network to target. Use
'TESTNET' during development and 'MAINNET' for production. All wallet operations — including transaction submission and contract reads — are directed to the selected network.object
Optional branding overrides that appear inside the SocketFi hosted authentication popup. Customize these to keep the sign-in experience consistent with your product’s visual identity.
(session: Session) => void
An optional callback invoked after the user successfully authenticates. Receives the full
Session object, including the user profile and the SocketFi access token. Use this as an alternative to await authenticate() when you prefer an event-driven integration style.(error: SocketFiError) => void
An optional callback invoked when any SDK operation fails. Receives a
SocketFiError with a code and message. See the Errors reference for the full list of error codes.Initialization example
Singleton pattern
Create oneSocketFi instance and export it for use across your application. Instantiating multiple instances can lead to duplicate authentication popups, inconsistent session state, and redundant network requests.
Your
clientId is available in the SocketFi Developer Portal under Applications → Your App → Settings. Keep your production clientId in an environment variable and never commit it directly to source control.