Skip to main content

Installation

Install the OTPless Headless SDK with your favorite package manager:

🚀 Quick Start (React Example)


🧑‍💻 API Reference

useOTPless()

Returns an object with:

on(event, handler?)

  • Subscribe to a single event:
  • Or to multiple events at once:
  • Returns an unsubscribe function.

off(event, handler)

  • Unsubscribe a specific event handler.

TypeScript Types & Constants


OTPless Response Type

All SDK calls (initiate, verify) return:
Example:

⚡️ Framework-Agnostic Usage

You can use the SDK without React (in any framework):

🛠 Utility Functions


🟢 Next.js Usage

For Next.js App Router, add 'use client'; at the top of your component file!

Find npm package here: https://www.npmjs.com/package/otpless-headless-js Find github repository here: https://github.com/otpless-tech/web-headless-demo Find sandbox here: https://codesandbox.io/s/github/otpless-tech/web-headless-demo

🏁 Checkpoint

To ensure a smooth integration process:
  1. Deploy your app/website with the included OTPLESS SDK.
  2. Conduct tests to verify the sign-in flow functions correctly.
  3. Ensure that after a successful sign-in, the user is redirected back to your app/website and their information is correctly logged in the console.

User Information Response Structure

The structure of the user information returned upon successful sign-in is as follows:
You can check out a complete sample response here.

Next Steps

Validate ID Token

Learn how to securely `validate ID token` returned by OTPLESS javascript SDK to ensure the authenticity of sign-in events from your backend server.

Validate Token (Opaque)

Learn how to securely `validate token` returned by OTPLESS javascript SDK to ensure the authenticity of sign-in events from your backend server.