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-form-preview

v0.1.2

Published

A React library for form preview functionality with react-hook-form

Readme

React Form Preview

A React library that provides real-time preview functionality for forms built with react-form. This library allows you to easily create live previews of form data as users type, with support for debounced updates.

Features

  • 🔄 Real-time form data preview
  • ⚡ Built for react-hook-form
  • 🎯 TypeScript support
  • ⏱️ Configurable debouncing

Installation

Using npm:

npm install react-form-preview

Using Yarn:

yarn add react-form-preview

Using Bun:

bun add react-form-preview

Usage

Basic Example

Here's a basic example of how to use the form preview functionality:

import { useForm } from 'react-form'
import { useFormPreview, FormPreviewProvider } from 'react-form-preview'

type FormData = {
  name: string
  email: string
}

function PreviewComponent({ data }: { data: FormData }) {
  return (
    <div>
      <h3>Preview</h3>
      <div>Name: {data.name}</div>
      <div>Email: {data.email}</div>
    </div>
  )
}

function MyForm() {
  const form = useForm<FormData>()
  const { previewData } = useFormPreview(form, {
    debounceDelay: 500 // Optional: configure debounce delay
  })

  return (
    <FormPreviewProvider value={{ previewData }}>
      <form onSubmit={form.handleSubmit(console.log)}>
        <input {...form.register('name')} />
        <input {...form.register('email')} type="email" />
        <button type="submit">Submit</button>
      </form>
      
      <PreviewComponent data={previewData} />
    </FormPreviewProvider>
  )
}

Creating Custom Preview Components

You can create your own preview components using the useFormPreviewContext. This allows you to access the preview data anywhere within the FormPreviewProvider:

type YourFormType = {
  name: string
  email: string
  // ... your form fields
}

function YourCustomPreview() {
  // Type the context with your form data type
  const { previewData } = useFormPreviewContext<YourFormType>()

  return (
    // Your custom UI here
    <div>
      {/* Access the preview data directly */}
      <p>{previewData.someField}</p>
    </div>
  )
}

// Use it in your form
function YourForm() {
  const form = useForm<YourFormType>()
  const { previewData } = useFormPreview(form)

  return (
    <FormPreviewProvider value={{ previewData }}>
      <div>
        {/* Your form fields */}
        <form>...</form>
        
        {/* Your custom preview component */}
        <YourCustomPreview />
      </div>
    </FormPreviewProvider>
  )
}

The preview component can be styled and structured however you want, and you can create multiple preview components that all access the same form data through the context.

API Reference

useFormPreview

function useFormPreview<T>(
  form: UseFormReturn<T>,
  options?: UseFormPreviewOptions
): { previewData: T }

Options:

  • useDebounce?: boolean - Whether to use debouncing (default: true)
  • debounceDelay?: number - Debounce delay in milliseconds (default: 300)

FormPreviewProvider

function FormPreviewProvider<T>({
  children,
  value
}: {
  children: ReactNode
  value: { previewData: T }
}): JSX.Element

useFormPreviewContext

function useFormPreviewContext<T>(): { previewData: T }

Development

To develop locally:

  1. Clone the repository
  2. Install dependencies:
    bun install
  3. Start development:
    bun run dev

Building with Bun

This library is compatible with Bun. To build:

bun run build

To test:

bun test

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT