npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@socketfi/react

v1.2.1

Published

React SDK for SocketFi embedded wallet authentication and transaction approval.

Readme

SocketFi React SDK

Embedded wallet authentication and transaction approval for React applications.


Installation

npm install @socketfi/react

or

yarn add @socketfi/react

Overview

SocketFi SDK allows applications to integrate seamless embedded wallet authentication and transaction approval flows directly inside their app.

Features include:

  • Embedded wallet authentication
  • Passkey-based onboarding
  • Hosted transaction approval
  • React hooks and provider support
  • Popup and redirect authentication flows
  • Soroban/Stellar transaction support
  • Minimal integration setup

Quick Start

1. Wrap Your App

import React from "react";
import ReactDOM from "react-dom/client";
import { SocketFiProvider } from "@socketfi/react";
import App from "./App";

ReactDOM.createRoot(document.getElementById("root")!).render(
  <SocketFiProvider
    config={{
      clientId: "YOUR_CLIENT_ID",

      network: "TESTNET",

      brand: {
        appName: "My App",
        logo: "https://example.com/logo.png",
        primaryColor: "#2F0FD1",
      },

      onAuthSuccess(session) {
        console.log("Authenticated:", session);
      },

      onError(error) {
        console.error(error);
      },
    }}
  >
    <App />
  </SocketFiProvider>
);

Notes

  • clientId is required.
  • You can use a test clientId during local development and testing.
  • brand configuration is optional.
  • appName, logo, and primaryColor are used to customize the hosted authentication and transaction approval UI.
  • network defaults to "PUBLIC" if not provided.

Using the SDK

Connect or Authenticate a Wallet

import { useSocketFi } from "@socketfi/react";

function Example() {
  const socketfi = useSocketFi();

  async function handleLogin() {
    const data = await socketfi.authenticate();

    console.log("session:", data.session);
    console.log("access token:", data.session.socketfiAccessToken);
    console.log("wallet:", data.session.address);
  }

  return <button onClick={handleLogin}>Continue with SocketFi</button>;
}

Notes

  • authenticate() opens the hosted SocketFi authentication popup.
  • Users can either sign in to an existing wallet or create a new wallet directly through the popup flow.
  • Successful authentication resolves with a SocketFiSession.
  • The onAuthSuccess callback configured in SocketFiProvider also receives the authenticated session data.
  • You can use either the returned promise result or the onAuthSuccess callback depending on your preferred integration flow.

Example using onAuthSuccess:

<SocketFiProvider
  config={{
    clientId: "YOUR_CLIENT_ID",

    onAuthSuccess(data) {
      console.log("Session:", data.session);
      console.log("access token:", data.session.socketfiAccessToken);
      console.log("wallet:", data.session.address);
    },
  }}
>
  <App />
</SocketFiProvider>

Transaction Submission and Approval

const result = await socketfi.requestTransaction({
  accessToken: session.accessToken,

  contractId: "CONTRACT_ID",

  callFunction: {
    name: "transfer",
  },

  argsXdr: [],

  feePreference: {
    asset: "asset-address",
    max: "10000000",
  },
});

console.log(result);

Notes

  • requestTransaction() opens the hosted SocketFi transaction approval popup.
  • Users review and approve the transaction directly through the hosted approval flow.
  • Successful approval resolves with the transaction response data.
  • The onTransactionSuccess callback configured in SocketFiProvider also receives the transaction result data.
  • accessToken should be the authenticated SocketFi session access token.
  • contractId is the target Soroban smart contract address.
  • callFunction.name is the contract function to invoke.
  • argsXdr should contain serialized Soroban contract arguments in XDR format.
  • feePreference is optional.
  • feePreference.asset specifies the asset address to use for fee payment.
  • feePreference.max specifies the maximum fee the application allows to be charged for the transaction in stroops.
  • If feePreference is not provided, the default wallet or application fee behavior is used. Fees may be deferred automatically or the transaction may fail if the maximum allowed deferred fee limit has been reached.
  • USDC and XLM are currently guaranteed supported assets for transaction fee payment.
  • Additional supported fee assets may be added in future updates.
  • If an unsupported fee asset is provided in feePreference.asset, the transaction will fail during validation.

Example using onTransactionSuccess:

<SocketFiProvider
  config={{
    clientId: "YOUR_CLIENT_ID",

    onTransactionSuccess(result) {
      console.log("Transaction result:", result);
    },
  }}
>
  <App />
</SocketFiProvider>

React Hooks

useSocketFi

Returns the active SocketFi SDK instance.

const socketfi = useSocketFi();

useSocketFiState

Subscribe to SDK state updates.

const state = useSocketFiState(socketfi);

Available state:

{
  loading: boolean;
  error: string;
}

Provider Configuration

{
  clientId: string;

  network?: "PUBLIC" | "TESTNET";

  returnTo?: string;

  brand?: {
    appName?: string;
    logo?: string;
    primaryColor?: string;
  };

  onAuthSuccess?: (
    session: SocketFiSession
  ) => void;

  onError?: (
    error: Error
  ) => void;

  onTransactionSuccess?: (
    result: any
  ) => void;
}

Supported Environments

  • React 18+
  • React 19+
  • Vite
  • Next.js
  • CRA
  • TypeScript

Security Notes

SocketFi uses hosted authentication and transaction approval flows to help applications integrate secure embedded wallet onboarding without exposing sensitive signing logic directly inside client applications.

SocketFi validates authenticated sessions and access tokens before protected wallet actions and hosted transaction approvals are processed.


Links

  • Website: https://socket.fi
  • Documentation: https://docs.socket.fi