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.
| Export | Summary |
|---|---|
TypeId | Literal type used as the boundary components' type identifier. |
TagsOf | The _tags of an error union. |
Unclaimed | The errors of E whose _tag isn't in Tags. |
Variance | Variance marker carrying the tags a boundary claims. |
UnclaimedResult | An 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. |
UseErrorBoundary | A 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. |
CatchTagProps | Props for a catchTags handler: the caught error, and reset. |
CatchTags | One optional handler per _tag of E (or per tag in Tags), each typed by the error with that tag. |
ErrorsOf | The 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. |
AtomErrorBoundaryProps | Props for an error boundary that catches one atom's failures by _tag. |
AtomErrorBoundary | Provides an error boundary for one atom that renders a handler per _tag of the atom's error, typed by the error with that tag. |
ErrorBoundaryComponent | A boundary component: renders the catchTags handler for the errors it claims and throws the rest to the boundaries above it. |
ErrorBoundary | A boundary component and its hook, which narrows the results read under it, named freely by destructuring. |
ErrorBoundaryOptions | Options for createErrorBoundary. |
createErrorBoundary | Creates 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.
| Export | Summary |
|---|---|
Source | What 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. |
ArgsOf | The arguments a source takes: a family's parameters, or none for an atom. |
SuccessOf | The success type of a source's AsyncResult. |
ErrorOf | The error type of a source's AsyncResult. |
HandleKey | A handle's serialization key, branded with its source. |
Handle | An atom a loader started: its source's arguments, and the atom's serialization key. |
LoadedHandle | A handle from Loader.ensure or Loader.fetch: they waited for the result, so the component that reads it renders without suspending. |
Hydration | Streams a server registry into the browser's, typed failures intact, and hydrates it without requesting anything again. |
Hydration.hydrated | Returns a serializable atom that keeps its hydrated value on its first read, instead of running its effect again. |
Hydration.dehydrate | Encodes a request registry's serializable atoms for the browser. |
Hydration.hydrate | Applies dehydrated state to the browser's registry. |
Loader | Starts atoms from route loaders, before anything renders, so nothing waterfalls. |
Loader.SettledResult | A settled AsyncResult: what ensure and fetch return. |
Loader.LeaseTTL | How long a loader's lease keeps an atom mounted when no component takes it over. |
Loader.prefetch | Starts a source's atom without waiting for it, and returns its handle. |
Loader.prefetchInBrowser | Starts 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.ensure | Starts a source's atom, waits only while it has no result, and returns a handle whose reader renders without suspending. |
Loader.fetch | Starts 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.result | Returns the settled result ensure or fetch waited for. |
Loader.Loader | The loader verbs as Promises over one registry, as the framework integrations put them on the router context. |
Loader.MakeOptions | Options for make. |
Loader.make | Creates the Promise verbs over one registry. |
RequestRegistry | A registry per server request. |
RequestRegistry.Seed | Prepares a request registry before the loader verbs start atoms in it, such as by setting an atom to the request's cookie. |
RequestRegistry.InitialValues | Atoms paired with the values a registry starts with, as AtomRegistry.make's initialValues takes them: build each pair with Atom.initialValue. |
RequestRegistry.Options | Options for make. |
RequestRegistry.make | Creates the registry for one server request. |
RequestRegistry.settled | Waits until a request registry's seed has settled and every atom a verb started while it ran has started. |
RequestRegistry.layer | A layer that provides a request registry as the AtomRegistry, disposed when the layer's scope closes. |
RequestRegistry.isRequestRegistry | Returns whether a registry was made by make, for one server request. |
useAtomResult | Reads 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. |
useHandleValue | Reads a handle without React Suspense, through the source that made it, and returns the atom's current result as it is. |
HydrationBoundaryProps | Props for HydrationBoundary: the request's registry in a server component, or the state it dehydrated anywhere else. |
HydrationBoundary | Hydrates the state a server registry dehydrated, streamed results included. |
RegistryProvider | Provides 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. |
WaterfallMode | What useAtomResult does in development when a read starts an atom that no loader, server component, event handler or useWaterfall started. |
WaterfallDetection | Sets how useAtomResult reports request waterfalls in the tree below. |
useWaterfall | Starts 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.
| Export | Summary |
|---|---|
RequestAtoms | One request's registry, with the loader verbs over it. |
AtomsContext | The router context atomsMiddleware sets: what react-router's createContext<RequestAtoms>() returns. |
MiddlewareArgs | The parts of React Router's middleware arguments atomsMiddleware uses. |
AtomsMiddlewareOptions | Options for atomsMiddleware. |
atomsMiddleware | Creates a root middleware that gives each server request its own registry, under the given router context. |
clientAtomsMiddleware | Creates 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.
| Export | Summary |
|---|---|
RequestAtoms | The loader verbs over the request registry of the server render in progress, with its registry. |
makeRequestAtoms | Creates the verbs and getRegistry over a request registry that seed prepares. |
getRegistry | Returns the request registry of the server render in progress. |
prefetch | Loader.prefetch on the request's registry: starts a source's atom, to stream it, and returns its handle. |
prefetchInBrowser | Loader.prefetchInBrowser on the request's registry: returns a handle whose atom the browser's read starts, without starting it on the server. |
ensure | Loader.ensure on the request's registry: starts a source's atom, waits for its result, and returns its handle. |
fetch | Loader.fetch on the request's registry: starts or refreshes a source's atom, waits for the new result, and returns its handle. |
run | Loader.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.
| Export | Summary |
|---|---|
DehydratedRouterAtoms | The key setupRouterAtoms adds to the router's dehydrated state. |
RouterAtomsOptions | Options for setupRouterAtoms. |
makeRegistry | Creates 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. |
setupRouterAtoms | Provides a registry to a TanStack router's app and streams it from the server to the browser. |