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

react-native-fn-forms

v1.2.4

Published

πŸš€ Smart form validation library for React Native with built-in validators, multi-country phone formatting (14+ countries), icon support, field matching, auto-save, OTP verification. Real-time validation, TypeScript support, accessibility-first, cross-pla

Readme

React Native FN Forms

πŸš€ The smartest form validation library for React Native πŸš€

npm npm downloads GitHub React Native

React Native FN Forms is an intelligent form validation library with built-in field-specific validators for email, phone numbers, names, credit cards, OTP verification, and more. Perfect for React Native apps that need smart, real-time form validation with seamless OTP verification flows.

🎯 Why Choose React Native FN Forms?

  • βœ… 10+ Built-in Validators - Email, phone, credit card, names, addresses, etc.
  • βœ… OTP Verification - Complete OTP input component with SMS auto-fill
  • βœ… Icon Support - Left/right icons with interactive features (password toggle, clear buttons)
  • βœ… Smart Auto-formatting - Phone numbers, credit cards format automatically
  • βœ… Real-time Validation - Instant feedback with customizable debouncing
  • βœ… TypeScript First - Full type safety and IntelliSense support
  • βœ… Accessibility Ready - Screen reader support and proper ARIA labels
  • βœ… Cross-platform - iOS, Android, and React Native Web
  • βœ… Zero Native Dependencies - Pure JavaScript, easy installation
  • βœ… Performance Optimized - Minimal re-renders, efficient validation

✨ Features

  • 🧠 Smart Field Validation - Built-in validators for common field types (name, email, phone, etc.)
  • πŸ” OTP Verification - Complete OTP component with SMS auto-fill (iOS/Android)
  • 🌍 Multi-Country Phone Formatting - Auto-format phone numbers for 14+ countries (US, UK, India, etc.)
  • 🎨 Icon Support - Left/right icons with interactive handlers (password toggle, clear button, etc.)
  • ⚑ Real-time Validation - Debounced validation with customizable timing
  • 🎯 React Native Optimized - Platform-specific input props and keyboard handling
  • πŸ“± Cross-platform - Works on iOS, Android, and React Native Web
  • πŸ”§ TypeScript Support - Full type safety and IntelliSense
  • β™Ώ Accessibility First - Built-in accessibility features and screen reader support
  • 🎨 Customizable - Flexible styling and custom validation rules
  • πŸ“¦ Pure JavaScript - No native dependencies, easy installation

πŸš€ Installation

npm install react-native-fn-forms
# or
yarn add react-native-fn-forms

πŸ“š Documentation

API Documentation

Guides

Examples

Additional Resources

πŸ“– Quick Start

import React from 'react';
import { View, Button } from 'react-native';
import { useSmartForm, FormProvider, SmartFormField, SmartOTPField } from 'react-native-fn-forms';

const MyForm = () => {
  const form = useSmartForm({
    fields: {
      name: {
        type: 'personName',
        required: true,
        minLength: 2,
      },
      email: {
        type: 'email',
        required: true,
      },
      phone: {
        type: 'phone',
        required: false,
      },
    },
  });

  const handleSubmit = async () => {
    await form.submitForm();
    if (form.isValid) {
      console.log('Form data:', form.values);
    }
  };

  return (
    <FormProvider value={form}>
      <View style={{ padding: 20 }}>
        <SmartFormField
          name="name"
          label="Full Name"
          placeholder="Enter your name"
        />

        <SmartFormField
          name="email"
          label="Email"
          placeholder="Enter your email"
        />

        <SmartFormField
          name="phone"
          label="Phone (Optional)"
          placeholder="Enter your phone number"
        />

        <Button title="Submit" onPress={handleSubmit} />
      </View>
    </FormProvider>
  );
};

οΏ½ OTP Verification Example

import { SmartOTPField } from 'react-native-fn-forms';

const OTPVerification = () => {
  const form = useSmartForm({
    fields: {
      email: { type: 'email', required: true },
      otp: { type: 'otp', required: true, length: 6 }
    }
  });

  return (
    <FormProvider value={form}>
      <View style={{ padding: 20 }}>
        <SmartFormField
          name="email"
          label="Email Address"
          placeholder="Enter your email"
        />

        <SmartOTPField
          name="otp"
          label="Verification Code"
          length={6}
          autoFocus={true}
          onComplete={(code) => console.log('OTP Complete:', code)}
        />

        <Button title="Verify" onPress={() => form.submitForm()} />
      </View>
    </FormProvider>
  );
};

🎨 Fields with Icons

import Icon from 'react-native-vector-icons/MaterialIcons';

const LoginForm = () => {
  const [showPassword, setShowPassword] = React.useState(false);
  const form = useSmartForm({
    fields: {
      email: { type: 'email', required: true },
      password: { type: 'password', required: true }
    }
  });

  return (
    <FormProvider value={form}>
      <View style={{ padding: 20 }}>
        <SmartFormField
          name="email"
          label="Email"
          placeholder="Enter your email"
          leftIcon={<Icon name="email" size={20} color="#666" />}
        />

        <SmartFormField
          name="password"
          label="Password"
          placeholder="Enter password"
          secureTextEntry={!showPassword}
          leftIcon={<Icon name="lock" size={20} color="#666" />}
          rightIcon={
            <Icon
              name={showPassword ? 'visibility' : 'visibility-off'}
              size={20}
              color="#666"
            />
          }
          onRightIconPress={() => setShowPassword(!showPassword)}
        />

        <Button title="Login" onPress={() => form.submitForm()} />
      </View>
    </FormProvider>
  );
};

πŸ” Built-in Field Types

| Field Type | Description | Auto-formatting | Validation | | --------------- | ------------------------------------------------ | ------------------------------ | ------------------------------ | | personName | Names with letters, spaces, hyphens, apostrophes | βœ… Capitalizes properly | βœ… Rejects numbers/symbols | | businessName | Business names with additional characters | βœ… Cleans spacing | βœ… Allows business punctuation | | email | Email addresses | βœ… Lowercase formatting | βœ… Email format validation | | phone | Phone numbers | βœ… Format: (123) 456-7890 | βœ… Valid phone patterns | | creditCard | Credit card numbers | βœ… Format: 1234 5678 9012 3456 | βœ… Luhn algorithm check | | currency | Monetary values | βœ… Format: 10.99 | βœ… Valid currency format | | username | Usernames | βœ… Lowercase, clean chars | βœ… Alphanumeric + _ - | | streetAddress | Street addresses | βœ… Title case | βœ… Address characters | | url | Web URLs | βœ… Add https:// if missing | βœ… Valid URL format | | password | Passwords | ❌ No formatting | βœ… Strength requirements | | otp | OTP codes (4/6/8 digits) | ❌ No formatting | βœ… Numeric validation |

πŸ”₯ Key Features

Auto-save & Draft Recovery

Automatic draft saving with flexible storage adapters:

import AsyncStorage from '@react-native-async-storage/async-storage';

const form = useSmartForm({
  fields: {
    email: { type: 'email', required: true },
    message: { type: 'text', required: true },
  },
  autoSave: {
    enabled: true,
    debounce: 1000,
    key: 'contact-form-draft',
    expirationDays: 7,
    storage: {
      save: async (key, data) => await AsyncStorage.setItem(key, data),
      load: async key => await AsyncStorage.getItem(key),
      remove: async key => await AsyncStorage.removeItem(key),
    },
  },
  onDraftFound: draft => {
    Alert.alert('Resume?', 'You have unsaved changes', [
      { text: 'Discard', onPress: () => form.clearDraft() },
      { text: 'Resume', onPress: () => form.loadDraft(draft) },
    ]);
  },
});

πŸ“– See auto-save & draft recovery guide β†’

Field Matching / Confirmation Fields

Built-in support for email and password confirmation:

const form = useSmartForm({
  fields: {
    email: { type: 'email', required: true },
    confirmEmail: {
      type: 'email',
      required: true,
      matchField: 'email',
      matchErrorMessage: 'Email addresses must match',
    },
    password: { type: 'password', required: true, minLength: 8 },
    confirmPassword: {
      type: 'password',
      required: true,
      matchField: 'password',
      matchErrorMessage: 'Passwords must match',
    },
  },
});

πŸ“– See confirmation fields example β†’

Validation Modes

Choose how and when validation happens:

const form = useSmartForm({
  validation: {
    mode: 'onChange', // Validate as user types
    debounce: 300, // Wait 300ms after typing stops
    showErrorsOn: 'touched', // Show errors after field interaction
  },
  fields: {
    /* ... */
  },
});

Custom Validation

Add your own validation logic, including async validation:

username: {
  type: 'username',
  required: true,
  customValidation: async (value) => {
    const available = await checkAvailability(value);
    return available ? null : 'Username taken';
  }
}

πŸ“– See advanced validation patterns β†’

Custom Styling & Components

Full control over appearance and behavior:

<SmartFormField
  name="email"
  style={styles.field}
  inputStyle={styles.input}
  errorStyle={styles.error}
/>

πŸ“– See styling guide β†’

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

πŸ“„ License

MIT License - see LICENSE file for details.

πŸ™ Support


Made with ❀️ for the React Native community