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

@kontsedal/olas-react

v0.0.6

Published

Olas React adapter — OlasProvider, useRoot, useQuery, useField, KeepAlive, useSuspendOnHidden.

Readme

@kontsedal/olas-react

The React adapter for Olas. Tiny binding layer (~230 LOC) on top of useSyncExternalStore. The root is created outside React and resolved via context — so React never owns the controller lifetime, no double-construction under StrictMode, and concurrent rendering is safe by construction.

Install

pnpm add @kontsedal/olas-react @kontsedal/olas-core @preact/signals-core react react-dom

react >= 18 is a peer dep (we rely on useSyncExternalStore).

30-second example

// counter.ts — controller defined outside React
import { defineController, signal, type ReadSignal } from '@kontsedal/olas-core'

export const counter = defineController(() => {
  const count = signal(0)
  return { count, inc: () => count.update((n) => n + 1) }
})

export type CounterApi = {
  count: ReadSignal<number>
  inc: () => void
}
// main.tsx — root constructed once
import { createRoot } from '@kontsedal/olas-core'
import { createRoot as createReactRoot } from 'react-dom/client'
import { OlasProvider } from '@kontsedal/olas-react'
import { counter } from './counter'
import { App } from './App'

const root = createRoot(counter, { deps: {} })

createReactRoot(document.getElementById('root')!).render(
  <OlasProvider root={root}>
    <App />
  </OlasProvider>,
)
// App.tsx — React reads signals via tiny hooks
import { use, useRoot } from '@kontsedal/olas-react'
import type { CounterApi } from './counter'

export function App() {
  const api = useRoot<CounterApi>()
  return <button onClick={api.inc}>{use(api.count)}</button>
}

API

| Export | Purpose | |---|---| | OlasProvider | Pass the root through React context. | | useRoot<Api>() | Resolve the provider's root api. Throws if no provider. | | useController<Api>(root) | Back-compat — takes root explicitly (useful in tests). | | use(signal) | Subscribe a component to one ReadSignal<T>. | | useQuery(state) | Bundle all 8 signals on an AsyncState<T> into one render trigger. | | useField(field) | Bundle all 5 signals on a Field<T> plus action methods. | | <KeepAlive> | Suspend a child controller on unmount, resume on remount. | | useSuspendOnHidden(controller) | Suspend when document.visibilitychange flips hidden. |

Full signatures and gotchas in ../../API.md.

Why useSyncExternalStore

useSyncExternalStore is React 18's official external-store API. It guarantees no tearing under concurrent rendering and works correctly under StrictMode's double-mount. Olas signals are external state from React's perspective; the adapter just bridges the two.

The internal pattern: every signal .subscribe() fires synchronously with the current value on subscribe. The adapter swallows that first fire (React already has the value from getSnapshot) and only translates actual changes into store-change notifications.

Fakes for tests

@kontsedal/olas-core/testing exports fakeField<T>(initial, overrides?) and fakeAsyncState<T>(overrides?) so a component test can be driven without building a real controller:

import { fakeField, fakeAsyncState } from '@kontsedal/olas-core/testing'

const profile = {
  draft: fakeField('hello'),
  user: fakeAsyncState({ data: { id: '1', name: 'Alice' } }),
}

render(<UserCard profile={profile} />)

The fakes satisfy the real Field<T> / AsyncState<T> types so they pass useField / useQuery without casts.

Further reading