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

capacitor-sms-otp-send-verify

v1.1.0

Published

Capacitor plugin to send SMS and send/verify OTP codes from iOS and Android — a free Twilio Verify alternative. Routes through your own paired Android phone via SMS8. Native iOS Swift + Android Kotlin bridges with web fallback. No per-OTP fees, no markups

Readme

capacitor-sms-otp-send-verify — SMS + OTP for Ionic / Capacitor, a free Twilio Verify alternative

npm version npm downloads Capacitor 5+ iOS 13+ Android 22+ License: MIT

Capacitor plugin to send SMS, send and verify OTP codes from your Ionic / Capacitor app on iOS and Android — routed through your own Android phone. No Twilio, no Vonage Verify, no MessageBird. No per-OTP fees, no markups, no A2P 10DLC. Free 5-day trial at sms8.io — no card.

import { SmsOtp } from 'capacitor-sms-otp-send-verify';

await SmsOtp.configure({ apiKey: 'sk_xxx' });
await SmsOtp.sendOtp({ phone: '+14155550100' });
const { verified } = await SmsOtp.verifyOtp({ phone: '+14155550100', code: '482937' });

Why this instead of Twilio Verify?

| | Twilio Verify / Vonage Verify | Capacitor SMS8 plugin | |---|---|---| | Per-OTP cost | $0.05 – $0.10 each | $0 (flat $29/mo unlimited) | | A2P 10DLC paperwork | Required in the US | Not required — P2P SMS from a real SIM | | Sender ID | Short code / random LCN | Your real mobile number | | Setup time | Days | Minutes | | Native iOS Swift + Android Kotlin | Yes (separate SDKs) | Yes (one plugin) | | Free trial | None | 5 days unlimited, no card |

Install

npm install capacitor-sms-otp-send-verify
npx cap sync

Then in your Capacitor project:

npx cap copy ios
npx cap copy android

Done. The plugin's native iOS Swift and Android Kotlin bridges are compiled into your app automatically.

Quick start

1. Get a free API key

  1. Sign up at sms8.io — 5-day trial, no card
  2. Install the SMS8 Android app, pair your phone
  3. Copy your API key from app.sms8.io/api.php

2. Configure the plugin

Call configure once, typically in your app's bootstrap or before the first send:

import { SmsOtp } from 'capacitor-sms-otp-send-verify';

await SmsOtp.configure({
  apiKey: process.env.SMS8_API_KEY,
  // baseUrl: 'https://mcp.sms8.io' (default, rarely needs override)
});

Production: never embed your master API key in the app bundle. Proxy through your backend and pass a short-lived token to the plugin.

3. Send an OTP

const result = await SmsOtp.sendOtp({
  phone: '+14155550100',
  length: 6,                                          // default 6
  template: 'Your YourApp code: {code}',              // optional
  expiresIn: 300,                                     // default 300s
  maxAttempts: 5,                                     // default 5
});
console.log('OTP id:', result.otpId, 'expires:', result.expiresAt);

4. Verify the code the user typed

const r = await SmsOtp.verifyOtp({ phone: '+14155550100', code: '482937' });
if (r.verified) {
  // Welcome the user
} else {
  // r.error, r.attemptsLeft
}

5. Send a plain SMS

await SmsOtp.sendSms({ phone: '+14155550100', message: 'Order shipped!' });

Full Ionic example with auto-fill

import { IonInput, IonButton } from '@ionic/react';
import { useState } from 'react';
import { SmsOtp } from 'capacitor-sms-otp-send-verify';

export function VerifyPhone() {
  const [phone, setPhone] = useState('');
  const [code, setCode]   = useState('');
  const [stage, setStage] = useState<'phone' | 'code'>('phone');

  return stage === 'phone' ? (
    <>
      <IonInput
        type="tel"
        autocomplete="tel"
        value={phone}
        onIonChange={(e) => setPhone(e.detail.value!)}
        placeholder="+14155550100"
      />
      <IonButton onClick={async () => {
        await SmsOtp.sendOtp({ phone });
        setStage('code');
      }}>Send code</IonButton>
    </>
  ) : (
    <>
      <IonInput
        inputmode="numeric"
        autocomplete="one-time-code"
        maxlength={6}
        value={code}
        onIonChange={(e) => setCode(e.detail.value!)}
      />
      <IonButton onClick={async () => {
        const { verified } = await SmsOtp.verifyOtp({ phone, code });
        if (verified) navigate('/dashboard');
      }}>Verify</IonButton>
    </>
  );
}

The autocomplete="one-time-code" + inputmode="numeric" attributes activate iOS "From Messages" keyboard suggestion and Android SMS Retriever auto-fill automatically.

API

configure(options): Promise<void>

| Option | Type | Default | Notes | |---|---|---|---| | apiKey | string | — | Required. Get one free at https://sms8.io | | baseUrl | string | https://mcp.sms8.io | Override server (self-hosted MCP) |

sendSms(options): Promise<SendResult>

| Option | Type | Notes | |---|---|---| | phone | string | E.164 phone number | | message | string | SMS body | | deviceId? | number | Pin a specific paired Android | | simSlot? | string | Pick a SIM slot (multi-SIM) |

Returns { success, messageId, phone, error }.

sendOtp(options): Promise<SendOtpResult>

| Option | Type | Default | Notes | |---|---|---|---| | phone | string | — | E.164 phone | | length | number | 6 | Digits in the code (4-8) | | template | string | "Your verification code is {code}" | Use {code} placeholder | | expiresIn | number | 300 | Seconds until expiry | | maxAttempts | number | 5 | Verification attempts allowed | | deviceId? | number | — | Pin a paired Android | | simSlot? | string | — | Pick a SIM |

Returns { success, otpId, phone, expiresAt, expiresIn, error }.

verifyOtp(options): Promise<VerifyOtpResult>

| Option | Type | Notes | |---|---|---| | phone | string | Same phone you sent the OTP to | | code | string | Code the user typed |

Returns { success, verified, error, attemptsLeft }.

How it works

When you call SmsOtp.sendOtp from your Ionic/Capacitor JavaScript code:

  1. On iOS → native Swift bridge in ios/Sources/... runs URLSession against https://mcp.sms8.io
  2. On Android → native Kotlin bridge in android/src/... runs HttpURLConnection against https://mcp.sms8.io
  3. In the browser → web fallback in dist/esm/web.js runs fetch against https://mcp.sms8.io

In all 3 cases the SMS8 backend queues the message, your paired Android phone polls SMS8, sends the SMS through its real SIM, and reports back. Typical round-trip: under 4 seconds.

Related packages

Links

License

MIT