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

rhf-preview

v0.0.3

Published

A small utility for viewing react-hook-form values in a quick and easy way

Readme

RHF Preview

A small utility for viewing react-hook-form values in a quick and easy way. This library provides a React component that displays form values, errors, touched fields, dirty fields, and form state in a clean, developer-friendly interface.

Features

  • Real-time Form Monitoring: Displays form values, errors, and state as they change.
  • React Hook Form Integration: Seamlessly integrates with react-hook-form for easy setup.
  • Portal-based UI: Renders a floating preview panel using React portals for flexible positioning.
  • Customizable Styling: Comes with CSS classes for easy styling customization.
  • TypeScript Support: Fully typed with TypeScript for a robust development experience.

Installation

Install the package using npm or yarn:

npm install rhf-preview

or

yarn add rhf-preview

Usage

  1. Ensure you have react, react-dom, and react-hook-form installed in your project.
  2. Wrap your form with the FormProvider from react-hook-form.
  3. Add the RHFPreview component to your form to display the preview panel.

Example

import { FormProvider, useForm } from "react-hook-form";
import RHFPreview from "rhf-preview";

function MyForm() {
    const methods = useForm({
        defaultValues: {
            name: "",
            email: "",
        },
    });

    return (
        <FormProvider {...methods}>
            <form>
                <input {...methods.register("name")} placeholder="Name" />
                <input {...methods.register("email")} placeholder="Email" />
                <button type="submit">Submit</button>
            </form>
            <RHFPreview />
        </FormProvider>
    );
}

export default MyForm;

How It Works

  • The RHFPreview component uses useFormContext from react-hook-form to access form state and values.
  • A button (rendered via a React portal) toggles the visibility of the preview panel.
  • The preview panel displays:
    • Form Values: All current form values.
    • Form State: Key form state properties (excluding certain fields like errors and touched fields).
    • Errors: Any validation errors for form fields.
    • Dirty Fields: Fields that have been modified.
    • Touched Fields: Fields that have been interacted with.

Props

The RHFPreview component does not accept any props directly, as it relies on the FormProvider context from react-hook-form.

Styling

The preview panel uses the following CSS classes for styling:

  • mainContainerStyles: The main container for the preview panel.
  • heading: The title of the preview panel.
  • typeContainer: Containers for each section (e.g., Form Values, Errors).
  • typeContainer__title: Section titles.
  • typeContainer__row: Rows within each section.
  • typeContainer__label: Labels for field names.
  • typeContainer__value: Values for fields.

You can override these styles by providing your own CSS. The styles are defined in global.css within the package.

Development

To contribute or modify the library:

  1. Clone the repository:
git clone https://github.com/JatinThakur-12/rhf-preview.git
  1. Install dependencies:
npm install
  1. Build the project:
npm run rollup

Scripts

  • npm run rollup: Builds the library using Rollup, generating CommonJS, ES modules, and TypeScript declaration files.
  • npm test: Placeholder for tests (not yet implemented).

Project Structure

  • src/index.tsx: Entry point for the RHFPreview component.
  • src/preview.tsx: Main preview panel component.
  • src/components/: Contains components for displaying form values, errors, state, etc.
  • src/global.css: Default styles for the preview panel.
  • rollup.config.js: Rollup configuration for building the library.
  • tsconfig.json: TypeScript configuration.

Dependencies

Peer Dependencies

  • react: ^18.0.0 || ^19.0.0
  • react-dom: ^18.0.0 || ^19.0.0
  • react-hook-form: ^7.0.0

Dev Dependencies

  • Rollup plugins for bundling and TypeScript support.
  • TypeScript for type checking.
  • PostCSS for CSS processing.

License

This project is licensed under the ISC License. See the package.json for more details.

Author

Jatin Thakur