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

raf-effect-atom

v0.3.3

Published

Render-as-you-fetch for Effect Atom: start atoms from route loaders and stream them into the browser, typed failures intact

Readme

raf-effect-atom

Render-as-you-fetch for Effect Atom. Route loaders start atoms before anything renders, the server streams their results into the browser, and the browser reads them without requesting them again. Typed failures survive the trip: a server-side IssueNotFound is an IssueNotFound in the browser.

GitHub

[!NOTE] raf-effect-atom is early. The API can still change between minor releases.

Install

npm install raf-effect-atom effect @effect/atom-react react

effect, @effect/atom-react and react (19.2 or newer) are peer dependencies.

Usage

A loader starts atoms with a verb per call, given an atom family and its arguments. prefetch starts one and streams it, ensure waits for its first result, and fetch waits for a fresh one. Each returns a handle, plain data naming the atom, which the loader returns for the page to pass down. Typed failures come back as results, so a loader can redirect on a tag:

import { Loader } from "raf-effect-atom";

// issue: (id: number) => an AtomRpc query with a serializationKey
export async function loader(args: LoaderArgs) {
	const id = Number(args.params.id);
	const handles = {
		comments: args.context.atoms.prefetch(comments, id),
		issue: await args.context.atoms.ensure(issue, id),
	};
	const result = Loader.result(handles.issue);
	if (AsyncResult.isFailure(result)) {
		// result.cause holds IssueNotFound | Unauthorized | RpcClientError
	}
	return handles;
}

A component takes the handle as a prop and reads it with useAtomResult(source, handle), which waits for a streamed result instead of starting the atom again, and returns typed failures. Given a handle instead of an id, it can't start a request of its own. An effect-atom-boundary boundary's hook takes the result, throws the errors that boundary claims to it, and returns the rest:

import { type Handle, useAtomResult } from "raf-effect-atom";

function IssueTitle(props: { readonly issue: Handle<typeof issue> }) {
	const result = useIssueBoundary(useAtomResult(issue, props.issue));
	// Success<Issue, never>: its boundaries claim every failure
	return <h1>{result.value.title}</h1>;
}

Each framework has a subpath that gives every server request its own registry and sends it to the browser:

  • raf-effect-atom/tanstack-router, for TanStack Router and TanStack Start: setupRouterAtoms({ router, registry }) in getRouter, with Loader.make(registry) on the router context.
  • raf-effect-atom/rsc, for React Server Components such as the Next.js App Router: prefetch, ensure and fetch in server components, which pass the handles to client components as props, and <HydrationBoundary registry={getRegistry()}> around them. HydrationBoundary and RegistryProvider come from raf-effect-atom itself: server components get the build that takes the request's registry through the react-server export condition. makeRequestAtoms({ seed }) makes the same functions over a registry seeded from the request, such as with its cookie.
  • raf-effect-atom/react-router, for Framework Mode: atomsMiddleware(atomsContext) as the root middleware and clientAtomsMiddleware(atomsContext) as its client middleware, loaders that return atoms.dehydrate() with their handles and double as client loaders, and <HydrationBoundary state={loaderData.atoms}> in the route component.

In development, useAtomResult reports a read that starts an atom nothing started, a request waterfall. <WaterfallDetection mode="throw"> at the root makes it throw to the nearest error boundary. useWaterfall(source, ...args) starts an atom whose input exists only in render, marks it as a known waterfall, and returns its handle.

For coding agents

Start every atom in a loader or a server component, never in a component or useEffect, and put the state that picks data (pages, filters, open dialogs) in the URL so the loader can. Event handlers and useWaterfall are escape hatches for state that can't be in the URL. Pass components the handles the loader returns, not ids, and read them with useAtomResult, not useAtomValue or useAtomSuspense. Keep <WaterfallDetection mode="throw"> at the root and fix what it reports instead of turning it off. The full rules, with the reason for each: For coding agents. The docs as markdown: llms.txt.

License

MIT