Skip to content

raf-effect-atom and effect-atom-boundary are on npm. Both are pre-1.0, so a minor release can still break them. Install them

raf-effect-atom

API reference

API reference

Every export of effect-atom-boundary and raf-effect-atom, with its signature and JSDoc, generated from the source.

effect-atom-boundary

Typed error boundaries for Effect Atom: catch an atom's failures by tag, typed by the atom. The full reference.

ExportSummary
TypeIdLiteral type used as the boundary components' type identifier.
TagsOfThe _tags of an error union.
UnclaimedThe errors of E whose _tag isn't in Tags.
VarianceVariance marker carrying the tags a boundary claims.
UnclaimedResultAn AsyncResult, or a union of them, typed without the errors whose _tag is in Tags: a failure with no error left is gone from the union, so a read whose failures are all claimed is typed as a success.
UseErrorBoundaryA boundary's hook: takes the result a component read under the boundary, throws the failures this boundary and the boundaries above it claim, and returns the result typed without them.
CatchTagPropsProps for a catchTags handler: the caught error, and reset.
CatchTagsOne optional handler per _tag of E (or per tag in Tags), each typed by the error with that tag.
ErrorsOfThe error type of what a boundary's errors names: an AtomRpc client (the errors of every procedure), an AtomHttpApi client (the errors of every endpoint and its middleware), an atom, or an atom family.
AtomErrorBoundaryPropsProps for an error boundary that catches one atom's failures by _tag.
AtomErrorBoundaryProvides an error boundary for one atom that renders a handler per _tag of the atom's error, typed by the error with that tag.
ErrorBoundaryComponentA boundary component: renders the catchTags handler for the errors it claims and throws the rest to the boundaries above it.
ErrorBoundaryA boundary component and its hook, which narrows the results read under it, named freely by destructuring.
ErrorBoundaryOptionsOptions for createErrorBoundary.
createErrorBoundaryCreates a shared error boundary that claims some errors by _tag, returned as [Boundary, useBoundary].

raf-effect-atom

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

ExportSummary
SourceWhat the verbs start and useAtomResult reads: an atom family, a function from arguments to an AsyncResult atom such as an AtomRpc query, or an AsyncResult atom that takes no arguments.
ArgsOfThe arguments a source takes: a family's parameters, or none for an atom.
SuccessOfThe success type of a source's AsyncResult.
ErrorOfThe error type of a source's AsyncResult.
HandleKeyA handle's serialization key, branded with its source.
HandleAn atom a loader started: its source's arguments, and the atom's serialization key.
LoadedHandleA handle from Loader.ensure or Loader.fetch: they waited for the result, so the component that reads it renders without suspending.
HydrationStreams a server registry into the browser's, typed failures intact, and hydrates it without requesting anything again.
Hydration.hydratedReturns a serializable atom that keeps its hydrated value on its first read, instead of running its effect again.
Hydration.dehydrateEncodes a request registry's serializable atoms for the browser.
Hydration.hydrateApplies dehydrated state to the browser's registry.
LoaderStarts atoms from route loaders, before anything renders, so nothing waterfalls.
Loader.SettledResultA settled AsyncResult: what ensure and fetch return.
Loader.LeaseTTLHow long a loader's lease keeps an atom mounted when no component takes it over.
Loader.prefetchStarts a source's atom without waiting for it, and returns its handle.
Loader.prefetchInBrowserStarts a source's atom in the browser, and returns its handle: on the server, it starts nothing, and the browser's read starts the atom.
Loader.ensureStarts a source's atom, waits only while it has no result, and returns a handle whose reader renders without suspending.
Loader.fetchStarts a source's atom, or refreshes it if it has a result, waits for the new result to settle, and returns a handle whose reader renders without suspending.
Loader.resultReturns the settled result ensure or fetch waited for.
Loader.LoaderThe loader verbs as Promises over one registry, as the framework integrations put them on the router context.
Loader.MakeOptionsOptions for make.
Loader.makeCreates the Promise verbs over one registry.
RequestRegistryA registry per server request.
RequestRegistry.SeedPrepares a request registry before the loader verbs start atoms in it, such as by setting an atom to the request's cookie.
RequestRegistry.InitialValuesAtoms paired with the values a registry starts with, as AtomRegistry.make's initialValues takes them: build each pair with Atom.initialValue.
RequestRegistry.OptionsOptions for make.
RequestRegistry.makeCreates the registry for one server request.
RequestRegistry.settledWaits until a request registry's seed has settled and every atom a verb started while it ran has started.
RequestRegistry.layerA layer that provides a request registry as the AtomRegistry, disposed when the layer's scope closes.
RequestRegistry.isRequestRegistryReturns whether a registry was made by make, for one server request.
useAtomResultReads a handle through React Suspense, through the source that made it: a result streamed from the server, a hydrated one, or one a loader started.
useHandleValueReads a handle without React Suspense, through the source that made it, and returns the atom's current result as it is.
HydrationBoundaryPropsProps for HydrationBoundary: the request's registry in a server component, or the state it dehydrated anywhere else.
HydrationBoundaryHydrates the state a server registry dehydrated, streamed results included.
RegistryProviderProvides the app's registry: a request registry while the framework renders the app on the server, and one registry for the page's lifetime in the browser.
WaterfallModeWhat useAtomResult does in development when a read starts an atom that no loader, server component, event handler or useWaterfall started.
WaterfallDetectionSets how useAtomResult reports request waterfalls in the tree below.
useWaterfallStarts a source's atom during render and returns its handle, for an input only a render knows, such as an id read from another atom's result.

raf-effect-atom/react-router

Connects the loader verbs to React Router's Framework Mode. The full reference.

ExportSummary
RequestAtomsOne request's registry, with the loader verbs over it.
AtomsContextThe router context atomsMiddleware sets: what react-router's createContext<RequestAtoms>() returns.
MiddlewareArgsThe parts of React Router's middleware arguments atomsMiddleware uses.
AtomsMiddlewareOptionsOptions for atomsMiddleware.
atomsMiddlewareCreates a root middleware that gives each server request its own registry, under the given router context.
clientAtomsMiddlewareCreates a root client middleware that gives client loaders the browser's registry, under the context atomsMiddleware uses on the server.

raf-effect-atom/rsc

Connects the loader verbs to React Server Components, such as the Next.js App Router. The full reference.

ExportSummary
RequestAtomsThe loader verbs over the request registry of the server render in progress, with its registry.
makeRequestAtomsCreates the verbs and getRegistry over a request registry that seed prepares.
getRegistryReturns the request registry of the server render in progress.
prefetchLoader.prefetch on the request's registry: starts a source's atom, to stream it, and returns its handle.
prefetchInBrowserLoader.prefetchInBrowser on the request's registry: returns a handle whose atom the browser's read starts, without starting it on the server.
ensureLoader.ensure on the request's registry: starts a source's atom, waits for its result, and returns its handle.
fetchLoader.fetch on the request's registry: starts or refreshes a source's atom, waits for the new result, and returns its handle.
runLoader.Loader's run on the request's registry: runs an Effect that needs the registry, such as the Effect verbs in an Effect.gen.

raf-effect-atom/tanstack-router

Connects the loader verbs to TanStack Router and TanStack Start. The full reference.

ExportSummary
DehydratedRouterAtomsThe key setupRouterAtoms adds to the router's dehydrated state.
RouterAtomsOptionsOptions for setupRouterAtoms.
makeRegistryCreates the registry for one getRouter call: a request registry on the server, and in the browser a registry like @effect/atom-react's RegistryProvider makes.
setupRouterAtomsProvides a registry to a TanStack router's app and streams it from the server to the browser.