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