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

@liveschema/react

v1.1.3

Published

React bindings for liveschema. `useLiveSchema(schema, values)` returns every declared field with an `isReachable` flag and enum options, the reachable subset, and an `isReachableField(key)` predicate for conditional rendering.

Downloads

90

Readme

@liveschema/react

React bindings for @liveschema/core. The useLiveSchema() hook walks a liveschema definition against your form's current values on every render and exposes the live reachable-field set — gate JSX with a predicate or iterate the reachable subset.

Install

pnpm add @liveschema/core @liveschema/react zod

Define a schema

Schemas are plain @liveschema/core definitions — defineSchema() plus .field() / .when() (see core for the full API). A minimal schema.ts:

import { z } from 'zod'
import { defineSchema } from '@liveschema/core'

export const schema = defineSchema()
  .field('orderType', z.enum(['pickup', 'delivery']))
  .when({ orderType: 'delivery' }, (b) => b.field('paymentMethod', z.enum(['card', 'cash'])))

paymentMethod only becomes reachable once orderType is 'delivery' — exactly what the hook gates on below.

Usage

Example with react-hook-form

import { useForm, useWatch } from 'react-hook-form'
import { standardSchemaResolver } from '@hookform/resolvers/standard-schema'
import { toStandardSchema } from '@liveschema/core'
import { useLiveSchema } from '@liveschema/react'
import { schema } from './schema'

export function MyForm() {
  const { register, control } = useForm({
    resolver: standardSchemaResolver(toStandardSchema(schema)),
  })
  const values = useWatch({ control })
  const { fields, isReachableField } = useLiveSchema(schema, values)

  return (
    <form>
      {fields.orderType.enumOptions?.map((o) => (
        <label key={o}>
          <input type="radio" value={o} {...register('orderType')} />
          {o}
        </label>
      ))}

      {isReachableField('paymentMethod') &&
        fields.paymentMethod.enumOptions?.map((o) => (
          <label key={o}>
            <input type="radio" value={o} {...register('paymentMethod')} />
            {o}
          </label>
        ))}
    </form>
  )
}

Return shape

| Property | Type | Meaning | | ------------------ | -------------------------------------------- | --------------------------------------------------------------------- | | fields | Record<Key, { isReachable; enumOptions? }> | Every declared field, keyed by name, in schema order. | | reachableFields | Partial<typeof fields> | The currently-reachable subset; unreachable keys are absent. | | isReachableField | (key) => boolean | Predicate equivalent to key in reachableFields. Use for JSX gating. |

Keys are typed via SchemaKeys<typeof schema>, so isReachableField('typo') is a compile error. enumOptions is only present on enum-like fields — accessing it on a string/boolean field is a compile error rather than undefined.

If you need the underlying validators (e.g. for per-field "Next"-button validation in a wizard), reach for reachableFields(schema, values) from @liveschema/core alongside the hook.

Examples