ThinkNimble Research

tn-forms
Active

tn-forms

Type-safe form management for TypeScript

A powerful TypeScript library for building and managing forms with full type safety, validation, and state management.

Overview

TN Forms is a TypeScript-first form library that provides robust form handling with complete type safety. It offers a flexible API for building complex forms while maintaining simplicity for basic use cases.

Features

Installation

# npm
npm install @thinknimble/tn-forms

# yarn
yarn add @thinknimble/tn-forms

# pnpm
pnpm add @thinknimble/tn-forms

Basic Usage

import { createForm } from "@thinknimble/tn-forms";

const form = createForm({
  email: {
    value: "",
    validators: ["required", "email"],
  },
  password: {
    value: "",
    validators: ["required", "minLength:8"],
  },
});

// Full type safety
form.fields.email.value = "user@example.com";
form.validate();

Key Concepts

Type-Safe Forms

Every form field is fully typed, providing autocomplete and compile-time checking for field names, values, and validation rules.

Validation Pipeline

A flexible validation system that supports:

State Management

Efficient state updates with:

Framework Integration

React

import { useForm } from "@thinknimble/tn-forms/react";

function MyForm() {
  const form = useForm({
    // form config
  });

  return <form onSubmit={form.handleSubmit}>{/* form fields */}</form>;
}

Vue

import { useForm } from "@thinknimble/tn-forms/vue";

export default {
  setup() {
    const form = useForm({
      // form config
    });

    return { form };
  },
};

Use Cases

Contributing

TN Forms is open source and welcomes contributions. Visit our GitHub repository to report issues or submit pull requests.