Skip to Content

🔐 OTP Verification

A sleek, customizable OTP verification screen for React Native apps. Supports themes, validation, background images, and full UI overrides. Ideal for login and onboarding flows.


✨ Features

  • 🔢 OTP input using react-native-confirmation-code-field

  • 📱 Shows phone number where OTP was sent

  • 🎨 Theme support (light/dark/custom)

  • ⏳ Resend OTP with countdown timer

  • 🖼️ Background image with optional gradient

  • 🔧 Render props for custom components:

    • Submit Button
    • OTP Input
    • Resend Button
    • Back Button
  • ⚙️ Keyboard-aware layout for better UX

  • 🔒 OTP length customizable (default: 4 digits)


📸 Preview

OTP-Light
OTP-Dark

📡 API Call

⚙️ First, setup the getZezoOtt API client: API Client Setup
🔗 Call getZezoOtt().auth.verifyOTP() to verify the OTP entered by the user.
📘 See method reference


👉 See Splash Screen Store Setup

🚀 Usage

OtpVerificationScreen.tsx
import React from "react"; import { Auth } from "@zezosoft/zezo-ott-react-native-ui-kit"; import { goBack } from "@ZezoOtt/utils/NavigationUtil"; import { useSplashStore } from "@ZezoOtt/store/splashStore"; const OtpVerificationScreen = () => { const { splash } = useSplashStore.getState(); return ( <Auth.OTP title="Verify your phone" phoneNumber="+919876543210" logoUri={splash.logo} backgroundImage={{ source: splash.login_poster, gradientSplitBackground: 0.4, }} resendDisabledTime={60} onTopBackBtnPress={() => goBack()} onSubmit={({ otp }) => { console.log("OTP Submitted:", otp); // Replace with your OTP verification logic }} onResendOtp={() => { console.log("Resend tapped"); // Replace with resend OTP logic }} text={{ otpSentText: "OTP has been sent to", submitButton: "Verify OTP", }} /> ); }; export default OtpVerificationScreen;

🔗 See related route definition: Route enum from @navigation/routes.ts


Props

📌 Core Configuration

PropTypeDescription
titlestringTitle displayed above the form
onSubmit(values: { otp: string }) => Promise<void> | voidCalled when OTP is submitted
onTopBackBtnPress() => voidHandler for top back button
logoUristringOptional logo image URL
phoneNumberstringPhone number displayed to the user
themeAppThemeOptional theme override
loadingbooleanShow loading spinner on submit button
otpDigitCountnumberNumber of digits for OTP input
keyboardTypeKeyboardTypeOptionsKeyboard type for OTP input (e.g., number-pad)
resendDisabledTimenumberCountdown in seconds before resend is enabled
onResendOtp() => voidCalled when resend button is tapped
textobjectObject to override labels, placeholders, etc.

🎨 Styling Props

PropTypeDescription
containerStyleViewStyleStyle override for outer container
titleStyleTextStyleStyle override for title text
formStyleViewStyleStyle override for the form container
backBtnStyleViewStyleStyle override for back button
cellStyleTextStyleStyle override for OTP input cells
focusCellStyleTextStyleStyle for focused OTP input cell

🖼️ Background Image

PropTypeDescription
backgroundImageobjectBackground image settings
 └── sourcestring | nullImage URL or local path
 └── resizeMode'cover' | 'contain' | 'stretch' | 'repeat'Image resizing behavior
 └── onImageError(error: Error) => voidCallback on image load failure
 └── gradientSplitBackgroundnumberGradient split position (e.g., 0.4 = 40%)

🧹 Custom Renderers

PropTypeDescription
renderLogo() => ReactNodeCustom renderer for logo
renderOtpHeader() => ReactNodeCustom renderer above OTP form
renderOtpInput(props: { value: string; onChange: (value: string) => void; isFocused: boolean[] }) => ReactNodeCustom OTP input fields
renderSubmitButton({ onPress, disabled, loading }) => ReactNodeCustom submit button
renderBackButton({ onPress }) => ReactNodeCustom back button
renderResendButton({ onPress, disabled }) => ReactNodeCustom resend button
renderPhoneText(phoneNumber: string) => ReactNodeCustom phone number display renderer

📝 Customizable Text

PropTypeDescription
textobjectCustomize field labels, placeholders, etc.
└─ otpLabelstringLabel above the OTP input field
└─ otpPlaceholderstringPlaceholder inside each OTP digit field
└─ submitButtonstringText shown on the submit/verify button
└─ loadingSubmitBtnTextstringText shown when the submit button is in loading state
└─ otpSentTextstringText prefix before the displayed phone number
└─ resendOtpTextstringText for the resend OTP button when enabled
└─ resendOtpCountdownTextstringCountdown text while resend is disabled (e.g., “in 30s”)

📝 Default Texts

These can be overridden using the text prop:

{ otpLabel: 'Enter OTP', otpPlaceholder: '••••', submitButton: 'Verify OTP', loadingSubmitBtnText: 'Verifying...', otpSentText: 'A One-Time OTP has been sent to', resendOtpText: 'Resend OTP', resendOtpCountdownText: 'Resend OTP in' }

✅ OTP Validation

  • Only numeric input allowed
  • Button disabled if OTP length is incomplete
  • onSubmit is called with OTP on success
  • onResendOtp is disabled during countdown

🔁 Resend Logic

  • Button disabled for resendDisabledTime seconds
  • Timer resets on each resend
  • Countdown can be customized or overridden

📀 Layout Overview

  • 🔙 Back Button (optional)
  • 🖼️ Logo (optional)
  • 📝 Title
  • 📱 Phone Number
  • 🔢 OTP Input
  • ✅ Submit Button
  • 🔁 Resend OTP with countdown

✍️ Created by Naresh Dhamu — Powered by ZezoSoft

Last updated on