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

@siymo/otp-sdk-react

v0.1.0

Published

React hooks SDK for inbound call and inbound SMS OTP flows built on top of @siymo/otp-sdk-core

Downloads

121

Readme

siymo-otp-react-sdk

React hooks SDK for inbound OTP client flows, powered by @siymo/otp-sdk-core.

What It Provides

  • useInboundCallOtp() for inbound call OTP sessions
  • useInboundSmsOtp() for inbound SMS OTP sessions
  • Build-time or browser default base URL resolution
  • Live WebSocket events for attempts, lock, verification, and expiry
  • Optional long-poll mode if a React client prefers HTTP waiting

Install

npm install siymo-otp-react-sdk @siymo/otp-sdk-core react

Default Behavior

If you do not pass a baseUrl, the hooks resolve it like this:

  1. Build-time env value from SIYMO_OTP_REACT_BASE_URL
  2. Build-time env value from SIYMO_OTP_BASE_URL
  3. Build-time env value from OTP_BASE_URL
  4. Build-time env value from baseURL
  5. Browser location.origin
  6. Fallback to http://localhost:3000

That lets you bake a service URL into the built package, while still keeping same-origin React apps working without extra configuration.

To build the package with a default service URL:

SIYMO_OTP_REACT_BASE_URL=http://localhost:3000 npm run build

Basic Usage

import { useInboundSmsOtp } from 'siymo-otp-react-sdk';

export function InboundSmsWidget() {
  const { data, error, loading, create, eventLog } = useInboundSmsOtp({
    onTried(event) {
      console.log('Try number:', event.data.attempts);
    },
    onSuccess() {
      console.log('OTP verified');
    },
  });

  async function handleStart() {
    await create({
      phone: '+998990649000',
      expiration: 60,
      maxTries: 3,
      qrCode: true,
    });
  }

  return (
    <div>
      <button onClick={handleStart}>Create session</button>
      <p>Loading: {loading ? 'yes' : 'no'}</p>
      <p>Status: {data.status}</p>
      <p>Attempts: {data.attempts}</p>
      <p>Tries left: {data.triesLeft ?? '-'}</p>
      <p>Decoded SMS: {data.decodedText ?? '-'}</p>
      {data.qrCodeImage ? <img src={data.qrCodeImage} alt="Inbound SMS QR code" width={180} /> : null}
      <p>Latest event: {eventLog.at(-1)?.description ?? '-'}</p>
      {error ? <p>{error.message}</p> : null}
    </div>
  );
}

Hook Return Shape

Both hooks expose:

  • data as the primary, flattened payload for the hook
  • loading, error, message, and called for easy UI state
  • create(request), restart(request?), wait(sessionId?), stop(), and clear()
  • Legacy aliases are still available: start, waitForSession, cancel, reset
  • eventLog with pre-described entries ready for rendering
  • Raw escape hatches when needed: session, events, lastEvent, lastAttemptEvent, verifiedEvent, lockedEvent, expiredEvent
  • attempts, triesLeft, status, isWaiting, isVerified, isLocked, isExpired

useInboundCallOtp() also exposes otpCode, callHref, and qrCodeImage.

useInboundSmsOtp() also exposes decodedText and qrCodeImage.

The data shape is channel-specific:

  • Call hook data: servicePhone, callerPhone, qrCodeImage, otpCode, callHref
  • SMS hook data: servicePhone, senderPhone, qrCodeImage, rawText, decodedText

Options

type UseInboundCallOtpOptions = {
  autoWait?: boolean;
  waitMode?: 'websocket' | 'long-poll';
  timeoutMs?: number;
  baseUrl?: string;
  websocketBaseUrl?: string;
  client?: SiymoOtpClient;
  clientOptions?: Omit<SiymoOtpClientOptions, 'baseUrl' | 'websocketBaseUrl'>;
  onCreated?: (session, result) => void;
  onSubscribed?: (event, result) => void;
  onTried?: (event, result) => void;
  onSuccess?: (event, result) => void;
  onLocked?: (event, result) => void;
  onExpired?: (event, result) => void;
  onError?: (error, result) => void;
  onStatusChange?: (status, result) => void;
};

Notes:

  • waitMode defaults to websocket
  • autoWait defaults to true
  • baseUrl still overrides any build-time default when you want a per-hook override
  • Pass qrCode: true in create() when you want the API to return a scannable qrCodeImage data URL
  • WebSocket mode is the only mode that can stream otp.attempt events live
  • Long-poll mode still updates verified / locked / expired state, but it cannot stream intermediate attempts
  • Callback handlers receive the latest hook result, including the derived data object

Examples

The package includes two basic React examples:

Each example consumes this React package plus the core @siymo/otp-sdk-core.