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

@tomorrowevening/theatre-react

v1.0.28

Published

Utilities for using [Theatre.js](https://www.theatrejs.com) or [Dataverse](https://github.com/theatre-js/theatre/tree/main/packages/dataverse) with React.

Readme

@tomorrowevening/theatre-react

Utilities for using Theatre.js or Dataverse with React.

Documentation

useVal(pointerOrPrism)

A React hook that returns the value of the given prism or pointer.

Usage with Dataverse pointers:

import {Atom} from '@tomorrowevening/theatre-dataverse'
import {useVal} from '@tomorrowevening/theatre-react'

const atom = new Atom({foo: 'foo'})

function Component() {
  const foo = useVal(atom.pointer.foo)
  return <div>{foo}</div>
}

Usage with Dataverse prisms:

import {prism} from '@tomorrowevening/theatre-dataverse'
import {useVal} from '@tomorrowevening/theatre-react'

const pr = prism(() => 'some value')

function Component() {
  const value = useVal(pr)
  return <div>{value}</div>
}

Usage with Theatre.js pointers:

import {useVal} from '@tomorrowevening/theatre-react'
import {getProject} from '@tomorrowevening/theatre-core'

const obj = getProject('my project')
  .sheet('my sheet')
  .object('my object', {foo: 'default value of props.foo'})

function Component() {
  const value = useVal(obj.props.foo)
  return <div>obj.foo is {value}</div>
}

Note that useVal() is a React hook, so it can only be used inside a React component's render function. val() on the other hand, can be used either inside a prism (which would be reactive) or anywhere where reactive values are not needed.

usePrism(fn, deps)

Creates a prism out of fn and subscribes the element to the value of the created prism.

import {Atom, val, prism} from '@tomorrowevening/theatre-dataverse'
import {usePrism} from '@tomorrowevening/theatre-react'

const state = new Atom({a: 1, b: 1})

function Component(props: {which: 'a' | 'b'}) {
  const value = usePrism(
    () => {
      prism.isPrism() // true
      // note that this function is running inside a prism, so all of prism's
      // hooks (prism.memo(), prism.effect(), etc) are available
      const num = val(props.which === 'a' ? state.pointer.a : state.pointer.b)
      return doExpensiveComputation(num)
    },
    // since our prism reads `props.which`, we should include it in the deps array
    [props.which],
  )
  return <div>{value}</div>
}

Note that just like useMemo(..., deps), it's necessary to provide a deps array to usePrism().

usePrismInstance(prismInstance)

Subscribes the element to the value of the given prism instance.

import {Atom, val, prism} from '@tomorrowevening/theatre-dataverse'
import {usePrismInstance} from '@tomorrowevening/theatre-react'

const state = new Atom({a: 1, b: 1})

const p = prism(() => {
  return val(state.pointer.a) + val(state.pointer.b)
})

function Component() {
  const value = usePrismInstance(p)
  return <div>{value}</div>
}

useAtom(initialValue)

/** Creates a new Atom, similar to useState(), but the component won't re-render if the value of the atom changes.

import {useAtom, useVal} from '@tomorrowevening/theatre-react'
import {useEffect} from 'react'

function MyComponent() {
  const atom = useAtom({count: 0, ready: false})

  const onClick = () =>
    atom.setByPointer(
      (p) => p.count,
      (count) => count + 1,
    )

  useEffect(() => {
    setTimeout(() => {
      atom.setByPointer((p) => p.ready, true)
    }, 1000)
  }, [])

  const ready = useVal(atom.pointer.ready)
  if (!ready) return <div>Loading...</div>
  return <button onClick={onClick}>Click me</button>
}

Links