Prerequisites
Before you begin, make sure you have:- React 18 or later
- TypeScript (recommended)
- A SocketFi application and Client ID from the SocketFi Dashboard
Protected routes
Redirect unauthenticated users away from sensitive pages:src/components/ProtectedRoute.tsx
Recommended project structure
Production tips
Switch
network from "TESTNET" to "MAINNET" when you deploy to production, and make sure VITE_SOCKETFI_CLIENT_ID points to your production Client ID.- Never trust client-side state alone. Always verify
socketfiAccessTokenwith@socketfi/serverbefore granting access to sensitive backend resources. - Use
localStoragefor convenience,sessionStoragefor stricter security. For highly sensitive applications, clear the session on tab close. - Wrap every SDK call in
try/catch. Users can cancel passkey prompts, network requests can time out, and contracts can revert. - Show descriptive intent before transactions. Users should understand exactly what they are signing — display the recipient, amount, and contract clearly in your UI before calling
requestTransaction. - Monitor errors in production. Pipe
onErrorevents to your observability tool (Sentry, Datadog, etc.) so you catch auth failures and transaction errors before users report them.