R

@robonen/vue

A collection of 213+ tree-shakeable, SSR-safe composables for Vue 3 — reactive primitives for state, sensors, the DOM, browser APIs, animation, forms and more.

Every Vue app ends up re-implementing the same building blocks: a toggle, a debounced ref, an event listener that cleans itself up, a media query, local-storage state. @robonen/vue ships those building blocks as small, composable functions with a consistent API. Each one is independently tree-shakeable, written in TypeScript with full inference, and safe to call during server-side rendering — guards for window, document and navigator are built in, so the same code runs on the server and hydrates cleanly on the client.

Tree-shakeable by design

Import only what you use. Each composable lives on its own and pulls in nothing it doesn't need — your bundle stays exactly as small as your usage.

SSR-safe out of the box

Browser-only access is guarded behind lifecycle hooks and configurable window/document targets, so Nuxt and SSR setups just work.

Fully typed

Written in TypeScript with precise return types and generics. MaybeRefOrGetter arguments mean you can pass plain values, refs or getters interchangeably.

Broad coverage

From state and reactivity to sensors, elements, storage, math and form handling — one cohesive toolkit spanning the whole surface of a Vue app.

Install

sh
pnpm add @robonen/vue

Quick start

Import the composables you need and use them inside <script setup>. Here's a counter clamped to a range, with auto-cleaning keyboard shortcuts:

ts
import { useCounter, useEventListener, useToggle } from '@robonen/vue';

// Clamped, reactive counter
const { count, increment, decrement, reset } = useCounter(0, { min: 0, max: 10 });

// A boolean toggle with custom truthy/falsy values
const { value: theme, toggle } = useToggle('light', {
  truthyValue: 'dark',
  falsyValue: 'light',
});

// Listener is removed automatically on unmount
useEventListener('keydown', (e) => {
  if (e.key === 'ArrowUp') increment();
  if (e.key === 'ArrowDown') decrement();
});

The same useCounter running live:

Where to next

The full API reference is listed right below. A few good starting points:

  • useCounter — a clamped, reactive counter with increment / decrement / set / reset.
  • useToggle — a boolean toggle with customizable truthy / falsy values.
  • useEventListener — declarative event listeners that clean up on unmount.
  • useStorage — reactive state synced to localStorage / sessionStorage.
  • useMagicKeys — reactive keyboard state for building shortcuts.

API Reference

Animation · 33

T
CubicBezierPointstesteddemo

Cubic bezier control points `[x1, y1, x2, y2]` (the implied endpoints are `(0, 0)` and `(1, 1)`), matching the CSS `cubic-bezier()` argument order.

T
CustomMeridiemtesteddemo

Signature for a custom meridiem (AM/PM) formatter.

T
DateLiketesteddemo

Accepted input for {@link useDateFormat}: a `Date`, a millisecond timestamp, a parseable date string, or `null`/`undefined` (resolves to "now").

T
EasingFunctiontesteddemo

An easing function mapping linear progress in `[0, 1]` to eased progress.

fn
formatDatetesteddemo

Format a `Date` against a token string. Exposed for one-shot, non-reactive formatting; {@link useDateFormat} wraps this in a `computed`.

fn
formatTimeAgotesteddemo

Pure (non-reactive) relative-time formatter. Useful on its own and reused by `useTimeAgo` on every tick.

I
FormatTimeAgoOptionstesteddemo

Options shared by the pure `formatTimeAgo` and the reactive `useTimeAgo`.

fn
normalizeDatetesteddemo

Coerce a {@link DateLike} into a `Date`. `null`/`undefined` become the current time; a non-UTC string is parsed leniently so partial dates such as `'2024-3'` are accepted.

T
TransitionEasingtesteddemo

The transition easing: either a cubic bezier tuple or a custom easing function.

T
TransitionInterpolationtesteddemo

Interpolates between two values of `T` given an eased progress `alpha`.

T
TransitionValuetesteddemo

Values that can be transitioned: a single number or a fixed-length number array.

fn
useAnimatetesteddemo

Reactive [Web Animations API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API) wrapper for a single element. Exposes imperative controls (`play`, `pause`, `reverse`, `finish`, `cancel`) alongside reactive state (`playState`, `currentTime`, `playbackRate`, ...). The reactive state is synced via `requestAnimationFrame` only while the animation is running, so an idle animation costs nothing. SSR-safe: nothing touches the DOM until the element resolves.

fn
useCountdowntesteddemo

Reactive countdown timer exposing the remaining seconds plus `start`/`stop`/`pause`/`resume`/`reset` controls and `onTick`/`onComplete` callbacks. Built on `useIntervalFn`, so it is SSR-safe and cleans up on scope dispose.

fn
useDateFormattesteddemo

Reactively format a `Date`, timestamp, or date string against a token string (`YYYY MM DD HH mm ss SSS dddd A` etc.). Recomputes when the date, format, or locale changes.

T
UseDateFormatReturntesteddemo

Reactive formatted date string.

fn
useIntervaltesteddemo

Reactive counter that increments on every interval tick.

fn
useIntervalFntesteddemo

Call a function on every interval. Supports reactive interval duration, pause/resume, and automatic cleanup on scope dispose.

fn
useNowtesteddemo

Reactive current `Date`, updated via `requestAnimationFrame` or a fixed interval.

I
UseNowControlstesteddemo

Pause/resume controls returned when `controls: true`.

fn
useRafFntesteddemo

Call a function on every `requestAnimationFrame` with delta time tracking. Automatically cleans up when the component scope is disposed.

fn
useTimeAgotesteddemo

Reactive relative time string (e.g. `'3 minutes ago'`) that ticks on a fixed interval. Fully customizable messages (i18n), units, rounding, and an automatic fallback to a full date once `max` is exceeded.

I
UseTimeAgoControlstesteddemo

Controls returned when `controls: true`.

T
UseTimeAgoFormattertesteddemo

Formatter for a single unit value. Receives the rounded numeric value and whether the instant is in the past, and returns the localized fragment.

T
UseTimeAgoMessagestesteddemo

Full message map: the built-in slots plus a formatter per unit name.

I
UseTimeAgoMessagesBuiltIntesteddemo

Built-in (non-unit) message slots.

I
UseTimeAgoOptionstesteddemo

Options for `useTimeAgo`.

I
UseTimeAgoUnittesteddemo

A single time unit used while resolving the most appropriate granularity.

T
UseTimeAgoUnitNametesteddemo

The default set of unit names recognized by `useTimeAgo`.

fn
useTimeouttesteddemo

Reactive boolean that flips to `true` after a given delay. Built on `useTimeoutFn`; optionally exposes `start`/`stop` controls. SSR-safe.

fn
useTimeoutFntesteddemo

Call a function after a given delay, with manual `start`/`stop` control and a reactive `isPending` flag. SSR-safe and cleans up on scope dispose.

fn
useTimestamptesteddemo

Reactive current timestamp, updated via `requestAnimationFrame` or a fixed interval.

I
UseTimestampControlstesteddemo

Pause/resume controls returned when `controls: true`.

fn
useTransitiontesteddemo

Reactively transition between numeric values (or numeric arrays) over a duration with configurable easing. Wraps a single, paused `requestAnimationFrame` loop that only runs while a transition is in flight, so it is cheaper than re-creating an RAF loop per change. SSR-safe: without a `window` the output tracks the source synchronously.

Array · 17

fn
useArrayDifferencetesteddemo

Reactive difference of two arrays. Returns items in `list` that are not in `values` (asymmetric), or items in exactly one array (symmetric). Both arrays may be reactive (refs or getters).

T
UseArrayDifferenceComparatorFntesteddemo

Comparator deciding whether two array elements are considered equal.

fn
useArrayEverytesteddemo

Reactive `Array.prototype.every`. The source array and its items may be reactive.

fn
useArrayFiltertesteddemo

Reactive `Array.prototype.filter`.

fn
useArrayFindtesteddemo

Reactive `Array.prototype.find`.

fn
useArrayFindIndextesteddemo

Reactive `Array.prototype.findIndex`.

fn
useArrayFindLasttesteddemo

Reactive `Array.prototype.findLast`.

fn
useArrayIncludestesteddemo

Reactive `Array.prototype.includes` with an optional comparator and `fromIndex`. The source array and its items may be reactive.

T
UseArrayIncludesComparatorFntesteddemo

Comparator deciding whether an array element equals the searched value.

fn
useArrayJointesteddemo

Reactive `Array.prototype.join`, with an optional reactive separator.

fn
useArrayMaptesteddemo

Reactive `Array.prototype.map`.

fn
useArrayReducetesteddemo

Reactive `Array.prototype.reduce`, with an optional initial value.

fn
useArraySometesteddemo

Reactive `Array.prototype.some`. The source array and its items may be reactive.

fn
useArrayUniquetesteddemo

Reactive de-duplicated array. By default uses `Set` identity (`===`); an optional key of `T`, key extractor (both O(n)), or full comparator (O(n²)) customizes equality. The source array and its items may be reactive. First-seen insertion order is preserved.

T
UseArrayUniqueComparatorFntesteddemo

Equality comparator deciding whether two array elements are duplicates.

T
UseArrayUniqueKeyFntesteddemo

Extracts the comparison key for an element. Two elements that produce the same key (via `===`/`Set` identity) are considered duplicates.

fn
useSortedtesteddemo

Reactive, stable sorted copy of an array. Mirrors `Array.prototype.sort` but never mutates the source by default and guarantees stable ordering.

Browser · 54

T
Breakpointstesteddemo

A breakpoints map: name → viewport width. Numbers are treated as pixels; strings keep their unit (`"48em"`, `"30rem"`, `"1024px"`). Values may be reactive (refs or getters).

fn
broadcastedReftesteddemo

Creates a custom ref that syncs its value across browser tabs via the BroadcastChannel API

T
ClipboardItemsValuetesteddemo

A value to copy: either concrete `ClipboardItems` or an (optionally async) getter that resolves to them.

T
ClipboardValuetesteddemo

A value to copy: either a string or an (optionally async) getter that resolves to one.

T
CloseWatcherHandlertesteddemo

Handler invoked when a close request is received. The argument is the native `close` event when the platform `CloseWatcher` is used, or the `Escape` `KeyboardEvent` when falling back to keydown.

T
FileDialogEventHookOntesteddemo

Subscribe to an event; returns an unsubscribe function.

I
FileSystemAccessShowOpenFileOptionstesteddemo

`window.showOpenFilePicker` parameters.

I
FileSystemAccessShowSaveFileOptionstesteddemo

`window.showSaveFilePicker` parameters.

T
FileSystemAccessWindowtesteddemo

A `window` augmented with the File System Access API entry points.

I
FileSystemFileHandletesteddemo
I
FileSystemWritableFileStreamtesteddemo
I
FileSystemWritableFileStreamWritetesteddemo
I
FontDatatesteddemo

A single font face exposed by the [Local Font Access API](https://developer.mozilla.org/en-US/docs/Web/API/FontData).

T
PermissionDescriptorNamePolyfilltesteddemo

Permission names not yet present in the lib DOM `PermissionName` union but supported by browsers behind the Permissions API.

fn
useBreakpointstesteddemo

Reactive viewport breakpoints derived from a breakpoints map. SSR-safe (resolves width queries from `ssrWidth` before `matchMedia` exists), reactive to breakpoint values, and built on a single `useMediaQuery` per comparison. Comes with presets: `breakpointsTailwind`, `breakpointsBootstrapV5`, `breakpointsAntDesign`, `breakpointsVuetifyV3`.

T
UseBreakpointsStrategytesteddemo

Which edge a generated shortcut property (e.g. `breakpoints.lg`) reacts to. - `'min-width'` (mobile-first) — `lg` is `true` when the viewport is at least the `lg` width. - `'max-width'` (desktop-first) — `lg` is `true` when the viewport is at most the `lg` width.

fn
useClipboardtesteddemo

Reactive async Clipboard API.

fn
useClipboardItemstesteddemo

Reactive async Clipboard API with rich `ClipboardItem` support (read/write images, HTML, and arbitrary MIME types — not just text). SSR-safe; uses passive `copy`/`cut` listeners and guards stale async writes.

fn
useCloseWatchertesteddemo

Wrap the native `CloseWatcher` API to handle close requests (the `Esc` key or the Android back gesture). Falls back to listening for `Escape` keydown when `CloseWatcher` is unavailable. SSR-safe.

fn
useColorModetesteddemo

Reactive color mode (`light` / `dark` / `auto`) with system detection, storage persistence, and automatic application of a class or attribute to a target element.

fn
useCssVartesteddemo

Read and write a CSS custom property on an element as a reactive ref. Defaults to `document.documentElement`. Set `observe` to react to external changes via a `MutationObserver`.

fn
useDarktesteddemo

Reactive dark mode boolean with system detection and storage persistence, built on `useColorMode`. Writing `false` while the system already prefers light (or `true` while it prefers dark) falls back to `'auto'`, so the mode keeps tracking the OS preference.

fn
useDocumentPiPtesteddemo

Reactive wrapper around the [Document Picture-in-Picture API](https://developer.mozilla.org/en-US/docs/Web/API/DocumentPictureInPicture) for rendering arbitrary DOM in an always-on-top window.

fn
useEventListenertesteddemo

Registers an event listener using the `addEventListener` on mounted and removes it automatically on unmounted Overload 1: Omitted window target

fn
useEyeDroppertesteddemo

Reactive wrapper around the [EyeDropper API](https://developer.mozilla.org/en-US/docs/Web/API/EyeDropper) for picking colors from the screen.

fn
useFavicontesteddemo

Reactive favicon.

fn
useFileDialogtesteddemo

Open a native file dialog programmatically and reactively track the selected files.

fn
useFileSystemAccesstesteddemo

Create, read, and write local files via the File System Access API.

T
UseFileSystemAccessCommonOptionstesteddemo

Picker options shared between open/create/save operations.

T
UseFileSystemAccessDataTypetesteddemo

The supported file data types.

T
UseFileSystemAccessShowSaveFileOptionstesteddemo

Picker options accepted by save-style operations.

fn
useFullscreentesteddemo

Reactive Fullscreen API for an element (or the document element). Handles vendor-prefixed fallbacks for request/exit/state detection and syncs `isFullscreen` from `fullscreenchange` events. SSR-safe.

fn
useImagetesteddemo

Reactively load an image in the browser; await the result to render it or show a fallback.

fn
useLocalFontstesteddemo

Reactive wrapper around the [Local Font Access API](https://developer.mozilla.org/en-US/docs/Web/API/Local_Font_Access_API) for enumerating the user's locally installed fonts.

fn
useMediaQuerytesteddemo

Reactive `window.matchMedia`. SSR-safe, reactive to the query, and with optional SSR width resolution for `min-width` / `max-width` queries.

fn
useObjectUrltesteddemo

Create and auto-revoke an object URL for a `Blob`, `File`, or `MediaSource`. The previous URL is revoked whenever the source changes, and the active URL is revoked on scope dispose.

fn
usePermissiontesteddemo

Reactive Permissions API state.

fn
usePreferredColorSchemetesteddemo

Reactive `prefers-color-scheme` media query.

fn
usePreferredContrasttesteddemo

Reactive `prefers-contrast` media query, resolving to the user's preferred contrast level. SSR-safe with an optional SSR fallback value.

fn
usePreferredDarktesteddemo

Reactive `prefers-color-scheme: dark` media query.

fn
usePreferredLanguagestesteddemo

Reactive `navigator.languages`. Tracks the user's preferred languages and updates automatically whenever the browser emits a `languagechange` event. Falls back to `['en']` during SSR or when no `window` is available, so the returned value is always a non-empty array.

fn
usePreferredReducedMotiontesteddemo

Reactive `prefers-reduced-motion` media query, resolving to `'reduce'` when the user requests reduced motion and `'no-preference'` otherwise. SSR-safe via {@link useMediaQuery}.

fn
usePreferredReducedTransparencytesteddemo

Reactive `prefers-reduced-transparency` media query, resolving to `'reduce'` or `'no-preference'`. SSR-safe (defaults to `'no-preference'`).

fn
useScriptTagtesteddemo

Dynamically inject and manage a `<script>` tag. The returned `load`/`unload` controls append the element to the document `<head>` (reusing an existing tag with the same `src`) and resolve once the script has loaded. Loading is de-duplicated, listeners are passive, and everything is SSR-safe.

fn
useSharetesteddemo

Reactive Web Share API wrapper to invoke the native share sheet.

fn
useStyleTagtesteddemo

Inject a reactive `<style>` tag into the document `<head>`. The CSS is a writable ref — assigning to it updates the live stylesheet. Multiple instances sharing an `id` reuse a single element via reference counting, and everything is SSR-safe.

fn
useTabLeadertesteddemo

Elects a single leader tab using the Web Locks API. Only one tab at a time holds the lock for a given key. When the leader tab closes or the scope is disposed, another tab automatically becomes the leader.

fn
useTextareaAutosizetesteddemo

Auto-resizes a `<textarea>` to fit its content. Reacts to user input, programmatic content changes, and element resize. Reuses `useEventListener` for a passive, auto-cleaned `input` listener and `useResizeObserver` to re-measure when the textarea's width changes (so reflowed text is re-fitted). SSR safe.

fn
useTitletesteddemo

Reactive `document.title`. Pass a getter to derive the title from other reactive state (returns a read-only ref), or a plain value/ref for two-way binding.

fn
useUrlSearchParamstesteddemo

Reactive `URLSearchParams` exposed as a plain reactive object. Reads from and (optionally) writes back to the URL using the `history`, `hash`, or `hash-params` location source. Listens for `popstate`/`hashchange` with passive listeners and pauses its own writer while syncing to avoid feedback loops. SSR-safe: returns the seeded reactive object when no `window` is available.

fn
useVibratetesteddemo

Reactive wrapper around the `navigator.vibrate` Vibration API.

fn
useWakeLocktesteddemo

Reactive wrapper over the Screen Wake Lock API to keep the screen awake. Re-acquires a deferred lock automatically when the document returns to visible.

fn
useWebNotificationtesteddemo

Reactive, SSR-safe wrapper around the Web Notification API with permission handling and `onClick`/`onShow`/`onError`/`onClose` event hooks.

I
WebNotificationOptionstesteddemo

Per-notification options mirroring the `Notification` constructor's `NotificationOptions`, plus the `title` argument folded in for convenience.

Component · 9

fn
createReusableTemplatetesteddemo

Define a template once and reuse it multiple times within the same component. Returns a `[DefineTemplate, ReuseTemplate]` pair (also destructurable as `{ define, reuse }`). The template captured by `DefineTemplate`'s default slot is rendered wherever `ReuseTemplate` appears, receiving its props/attrs as slot bindings. Supports a generic for typed bindings, typed slots, custom `props`, and `inheritAttrs`. Render-only and fully SSR-safe — it never touches `window`/`document`. The pair is created lazily and shares a single `shallowRef` for the captured render function, so there are no watchers and no per-render allocations beyond the vnode itself.

T
ReusableTemplatePairtesteddemo

The pair returned by {@link createReusableTemplate}. Usable both as a tuple (`const [Define, Reuse] = ...`) and as an object (`const { define, reuse } = ...`).

fn
unrefElementtesteddemo

Unwraps a Vue element reference to get the underlying instance or DOM element.

fn
useCurrentElementtesteddemo

Reactive root DOM element of the current component instance. Resolves to `vm.$el` (or the unwrapped `rootComponent` ref when provided) and is re-read on `onMounted` and `onUpdated` via a controlled computed — so it stays correct across re-renders without an always-on watcher. Generic over the element type; the type is inferred from the component's `$el` when available. SSR-safe: returns `undefined` until the component is mounted on the client.

T
UseCurrentElementReturntesteddemo

Infer the resolved element type. When no explicit generic is supplied (`T` stays the broad `MaybeElement`) we fall back to the component instance's `$el` type — unless that is `any` (the un-typed default), in which case we keep `MaybeElement`.

fn
useForwardExposetesteddemo

Forwards a child component's exposed API and DOM element (`$el`) through the parent component. Useful for wrapper / headless components that need to transparently proxy the inner component's ref to the consumer. Merges the parent's own props and any prior `expose()` bindings onto `instance.exposed`, then updates them when `forwardRef` is called with a child element or component instance.

fn
useTemplateRefsListtesteddemo

Collects a dynamic list of template refs for use with `v-for`. Automatically clears the list before each component update and repopulates it with fresh element references. Handles both plain DOM elements and Vue component instances (unwraps `$el`). Uses a non-reactive buffer internally to collect refs during the render cycle, then flushes to a `shallowRef` in `onMounted`/`onUpdated` to avoid triggering recursive update loops.

fn
useVirtualListtesteddemo

Virtualize a large list so only the items inside (and slightly around) the viewport are rendered. Supports vertical (`itemHeight`) and horizontal (`itemWidth`) layouts, fixed or per-index sizes, and an `overscan` buffer. Backed by `useElementSize` (reactive container size) and `useEventListener` (passive, auto-cleaned scroll handling). SSR-safe: renders an empty window until the container mounts.

T
UseVirtualListItemSizetesteddemo

Fixed pixel size or a per-index getter.

Debug · 2

Elements · 18

fn
onElementRemovaltesteddemo

Fire a callback when the target element — or any ancestor containing it — is removed from the DOM. Backed by a single `childList`/`subtree` `MutationObserver` on the element's owning document, so it also catches removal of a parent further up the tree.

fn
useActiveElementtesteddemo

Reactive `document.activeElement`, traversing open shadow roots.

fn
useDocumentReadyStatetesteddemo

Reactive `document.readyState` (`loading` | `interactive` | `complete`), updated on `readystatechange`.

fn
useDocumentVisibilitytesteddemo

Reactive `document.visibilityState`.

fn
useDraggabletesteddemo

Make an element draggable by pointer, tracking its position with optional axis locking, a drag handle, container constraints, and lifecycle callbacks. SSR-safe and built on passive pointer listeners.

fn
useDropZonetesteddemo

Create a drag-and-drop file drop zone on a target element or document.

fn
useElementBoundingtesteddemo

Reactive bounding box of an element (`getBoundingClientRect`), kept in sync via `ResizeObserver`, `MutationObserver`, and window scroll/resize. Supports deferring reads to the next animation frame to avoid layout thrash.

fn
useElementSizetesteddemo

Reactive size of an element, backed by `ResizeObserver`. Measures synchronously on mount, handles SVG elements via `getBoundingClientRect`, and sums multiple box fragments (e.g. multi-column layouts).

fn
useElementVisibilitytesteddemo

Track whether an element is visible within the viewport (or a custom scroll root), backed by `IntersectionObserver`.

fn
useFocusGuardtesteddemo

Adds a pair of focus guards at the boundaries of the DOM tree to ensure consistent focus behavior

fn
useIntersectionObservertesteddemo

Detect when an element enters or leaves the viewport via `IntersectionObserver`. Accepts a single target, an array of targets, or a ref/getter resolving to either, plus reactive `rootMargin` and `threshold`.

fn
useMutationObservertesteddemo

Watch for changes to the DOM tree via `MutationObserver`. Accepts a single target, an array of targets, or a getter returning either.

fn
useParentElementtesteddemo

Reactive `parentElement` of a given element (or the current component instance's root element when no target is supplied). Resolves the target through `unrefElement`, so it accepts plain elements, template refs, component instances, getters and computed refs. A single `immediate` watcher tracks the resolved target and re-reads its parent only when the element itself changes — no extra lifecycle hooks or always-on observers. SSR-safe: stays `undefined` until the target is resolved on the client.

fn
useResizeObservertesteddemo

Reports changes to the dimensions of an element via `ResizeObserver`. Accepts a single target or an array of (reactive) targets. The observer is recreated only when the resolved elements change, and can be paused/resumed.

fn
useWindowFocustesteddemo

Reactively track whether the window is focused via `focus`/`blur` events.

fn
useWindowScrolltesteddemo

Reactive window scroll position with arrived/direction tracking. Writing to `x`/`y` scrolls the window.

fn
useWindowSizetesteddemo

Reactive window size. Tracks the inner viewport, the outer window, or the visual viewport (pinch-zoom aware), and reacts to resize and orientation changes.

T
WindowSizeTypetesteddemo

Which window dimensions to track. - `'inner'` — `window.innerWidth/innerHeight` (or `documentElement.clientWidth/clientHeight` when `includeScrollbar` is `false`). The viewport size. - `'outer'` — `window.outerWidth/outerHeight`. The whole browser window, including chrome. - `'visual'` — `window.visualViewport` size, accounting for pinch-zoom scale. Useful on mobile where the visual viewport differs from the layout viewport.

Forms · 4

Lifecycle · 4

Math · 23

fn
createGenericProjectiontesteddemo

Create a reusable projection between two arbitrary (non-numeric) domains using a custom projector. The returned factory turns a reactive input into a `ComputedRef` of the projected value, so the same projection can be applied to many inputs without re-resolving the domains each time.

fn
createProjectiontesteddemo

Create a reusable numeric projection from one numeric domain to another. Without a custom projector it performs a linear (lerp-based) remap that extrapolates past the bounds; pass `{ clamp: true }` to clamp the input to the `from` domain via the stdlib `remap`. The returned factory can be reused for many inputs.

fn
logicAndtesteddemo

Reactive logical `AND` across boolean refs or getters. The result is `true` only when every input resolves to a truthy value.

fn
logicNottesteddemo

Reactive logical `NOT` of a boolean ref or getter. The result is `true` whenever the input resolves to a falsy value.

fn
logicOrtesteddemo

Reactively compute the logical `OR` across a list of boolean sources (each a ref, getter, or raw value). Returns a `ComputedRef<boolean>` that is `true` when at least one source is truthy. Short-circuits on the first truthy source, so later refs are only read when needed. With no arguments the result is `false` (the identity for `OR`). Fully SSR-safe — touches no globals.

T
ProjectorFunctiontesteddemo

A pure mapping from a value in the `from` domain to the `to` domain.

fn
useAbstesteddemo

Reactive `Math.abs` of a number ref or getter

fn
useAveragetesteddemo

Reactively compute the average (arithmetic mean) of the provided numbers. Accepts either a variadic list of numbers (each a ref, getter, or raw value) or a single reactive array whose items may themselves be refs/getters. Returns `NaN` when there are no values, mirroring `0 / 0`.

fn
useCeiltesteddemo

Reactive `Math.ceil`. Rounds a number up to the next largest integer.

fn
useClamptesteddemo

Clamps a value between a minimum and maximum value

fn
useFloortesteddemo

Reactive `Math.floor`. Returns the largest integer less than or equal to the given value

fn
useMathtesteddemo

Reactive wrapper over any callable `Math.<key>` method. Each argument may be a plain value, a ref or a getter; the result recomputes lazily whenever a reactive input changes.

T
UseMathArgstesteddemo

Maps each argument of a `Math` method to a reactive equivalent (`MaybeRefOrGetter`), so callers may pass plain values, refs or getters.

T
UseMathKeytesteddemo

Keys of `Math` that resolve to callable methods (excludes numeric constants such as `Math.PI` or `Math.E`).

T
UseMathReturntesteddemo

Reactive result of the wrapped `Math` method.

fn
useMaxtesteddemo

Reactively compute the maximum of the provided numbers. Accepts either a variadic list of numbers (each a ref, getter, or raw value) or a single reactive array whose items may themselves be refs/getters.

fn
useMintesteddemo

Reactive `Math.min`. Accepts a variadic list of numbers (each a ref, getter, or plain value) or a single reactive array whose items may themselves be refs/getters.

fn
usePrecisiontesteddemo

Reactively set the decimal precision of a number.

fn
useProjectiontesteddemo

Reactive numeric projection from one numeric domain to another. A thin one-shot wrapper over {@link createProjection}: it projects a single reactive `input` and returns a `ComputedRef` of the result. The default (lerp-based) projector extrapolates past the domain bounds; pass `{ clamp: true }` to clamp the input to the `from` domain. SSR-safe — it performs only pure arithmetic and touches no browser globals.

T
UseProjectiontesteddemo

A reusable projection: given a reactive input it yields a `ComputedRef` of the projected value.

fn
useRoundtesteddemo

Reactive `Math.round` with optional decimal-place precision

fn
useSumtesteddemo

Reactively compute the sum of the provided numbers. Accepts either a variadic list of numbers (each a ref, getter, or raw value) or a single reactive array whose items may themselves be refs/getters.

fn
useTrunctesteddemo

Reactive `Math.trunc`. Returns the integer part of a number by removing any fractional digits.

Media · 15

T
MediaEventHookOntesteddemo

Subscribe to a media event hook; returns an unsubscribe handle.

I
MemoryInfotesteddemo

Non-standard `performance.memory` heap statistics.

fn
useBluetoothtesteddemo

Reactive Web Bluetooth API. Prompts for a device and tracks its GATT server connection.

fn
useDisplayMediatesteddemo

Reactive `mediaDevices.getDisplayMedia` (screen share) streaming.

fn
useMediaControlstesteddemo

Reactive controls and state for an `<audio>`/`<video>` element: play/pause, seeking, duration, buffered ranges, volume, mute, rate, text tracks, and Picture-in-Picture. Source and track injection are handled for you, and all DOM listeners attach passively with automatic cleanup. SSR-safe.

I
UseMediaSourcetesteddemo

A media `<source>` descriptor injected as a child `<source>` element. Many of these definitions mirror MDN's HTMLMediaElement documentation.

I
UseMediaTextTracktesteddemo

A reactive snapshot of a single `TextTrack`.

I
UseMediaTextTrackSourcetesteddemo

A text track `<track>` descriptor injected as a child `<track>` element.

fn
useMemorytesteddemo

Reactive `performance.memory` heap statistics, polled on an interval. SSR-safe and a no-op where the API is unavailable.

fn
usePerformanceObservertesteddemo

Observe performance metrics via `PerformanceObserver`. The observer is (re)created only when activation changes, and can be paused, resumed, or permanently stopped. SSR-safe: nothing runs until mounted in a supporting environment.

fn
useSpeechRecognitiontesteddemo

Reactive wrapper around the Web Speech API `SpeechRecognition` for transcribing speech to text.

fn
useSpeechSynthesistesteddemo

Reactive wrapper around the Web Speech `SpeechSynthesis` API for text-to-speech.

fn
useUserMediatesteddemo

Reactive `navigator.mediaDevices.getUserMedia` streaming. Acquires a `MediaStream` for camera/microphone capture, keeps it in sync with reactive constraints, and auto-restarts on constraint changes while enabled. SSR-safe and race-safe — overlapping acquisitions never leave an orphaned stream open.

fn
useWebWorkertesteddemo

Simple Web Worker communication with reactive incoming data and automatic teardown

fn
useWebWorkerFntesteddemo

Run an expensive function in a transient Web Worker off the main thread

Reactivity · 29

T
AsyncComputedOnCanceltesteddemo

Handle overlapping async evaluations. The provided callback is invoked when a re-evaluation of the computed value is triggered before the previous one finished, letting you abort stale work.

fn
cloneFnDefaulttesteddemo

Default clone implementation. Prefers the structured clone algorithm and falls back to a JSON round-trip when `structuredClone` is unavailable (older runtimes / SSR) or the value is not structured-cloneable.

fn
computedAsynctesteddemo

Computed value driven by an async (promise-returning) evaluation callback. The value updates reactively when its dependencies change, exposing an optional `evaluating` ref for pending state, an `onError` handler, lazy evaluation, and a default value used until the first resolution settles. Out-of-order resolutions are discarded so only the latest run wins, and an `onCancel` hook lets callbacks abort stale work.

fn
computedEagertesteddemo

Eager (non-lazy) computed value backed by a `watchEffect`-driven `shallowRef`. Unlike `computed`, the getter runs immediately and on every dependency change rather than lazily on read, so the cached value is always up to date. Best for cheap derived values that are read in many places.

fn
computedWithControltesteddemo

A computed ref whose recomputation is driven only by an explicitly declared dependency `source`, plus a manual `.trigger()`. Built on `customRef` with a single `flush: 'sync'` watcher and a lazy `dirty` flag, so the getter is cached and only re-runs when the source changes or you trigger it — never on unrelated reactive reads. Also exposes `.peek()` (untracked read) and `.stop()` (detach the source watcher).

fn
extendReftesteddemo

Attach extra (optionally reactive) attributes to a ref while keeping it a usable ref.

fn
reactiveComputedtesteddemo

Computed that resolves to a reactive object whose individual fields stay reactive — read a single property and only that property is tracked, instead of the whole getter re-running on every access. The getter is wrapped in a single cached `computed`, so the object is recomputed only when one of its reactive dependencies changes. The returned value is a `reactive` proxy over that computed: destructuring with `toRefs`, spreading and writing back individual fields all work as on a normal `reactive` object.

fn
reactiveOmittesteddemo
T
ReactiveOmitPredicatetesteddemo

Predicate deciding, per field, whether a key should be omitted. Return `true` to drop the field.

T
ReactiveOmitReturntesteddemo

Resolved type of `reactiveOmit`: a reactive object that drops either the listed keys (`Omit`) or — when a predicate is used — an arbitrary subset (`Partial`), since the kept keys are only known at runtime.

fn
reactivePicktesteddemo

Reactively pick a subset of keys (or keys matched by a predicate) from a reactive object. The result is a live `reactive` proxy: reads forward to the source's current value (so it tracks reassignment of nested refs) and writes pass straight back to the source. Unlike a `computed` of an object literal, no new object is allocated per recompute — the proxy is built once and lookups are resolved lazily on access.

T
ReactivePickPredicatetesteddemo

Predicate form: receive each `(value, key)` pair of the source object and return `true` to keep the key in the resulting reactive view.

T
ReactivePickReturntesteddemo

The reactive object produced by {@link reactivePick}: a subset of `T` restricted to the picked keys `K`, with each value unwrapped.

fn
refAutoResettesteddemo

Create a ref that resets to its default value after a delay since the last write. Each set restarts the timer; reading is reactive.

fn
refDebouncedtesteddemo

A readonly ref whose value mirrors a source but only after updates stop arriving for `ms`. Wraps the source change in our debounce primitive (built on `debounceFilter`), so rapid bursts collapse into a single delayed write. Supports a `maxWait` ceiling so the value still progresses under sustained input, and tears its timer down with the owning scope.

fn
refDefaulttesteddemo

Wrap a writable `ref` so that reads fall back to a default value whenever the source holds `null` or `undefined`, while writes pass straight through to the source. The default may itself be reactive (a ref, getter, or plain value), so the fallback can track other state. Implemented as a single writable `computed` — no watchers, no extra refs, nothing to tear down — which keeps it allocation-light and SSR-safe (it never touches the DOM).

fn
refThrottledtesteddemo

A ref whose value updates are throttled. The returned ref mirrors the source but propagates changes at most once per `delay` window, making it useful for rate-limiting reactive updates driven by high-frequency events such as `scroll` or `resize`.

fn
refWithControltesteddemo

A ref with fine-grained control over its reactivity: read/write without tracking or triggering, plus `onBeforeChange` (vetoable) and `onChanged` hooks. Built on `customRef`, so there are no extra watchers.

fn
syncReftesteddemo

Keeps two refs in sync (two-way by default, or one-way via `direction`), with optional value transforms.

I
SyncRefTransformtesteddemo

Conversion functions used when the two refs hold different value types. - `ltr` maps a left value to a right value (used when the left ref changes). - `rtl` maps a right value to a left value (used when the right ref changes).

fn
toReactivetesteddemo

Convert a ref of object to a reactive proxy. Property reads and writes pass straight through to the ref's current value, so the proxy stays in sync even if the ref is reassigned to a whole new object. Writing a plain value onto a key that currently holds a ref unwraps into that ref's `.value`. Passing a plain object simply returns `reactive(object)`.

fn
useCachedtesteddemo

Caches the value of an external ref and updates it only when the value changes

fn
useClonedtesteddemo

Reactive deep clone of a source with a mutable cloned ref, modification tracking, and manual mode.

fn
useDebounceFntesteddemo

Debounce execution of a function — a thin reactive wrapper around `@robonen/stdlib`'s `debounce`. Postpones invocation until `ms` have elapsed since the last call and resolves with the wrapped function's result. Supports a reactive delay, a `maxWait` ceiling, `rejectOnCancel`, and exposes `cancel`, `flush`, and `isPending`. Pending timers are cleared on scope dispose.

fn
usePrevioustesteddemo

Track the previous value of a ref, getter, or reactive source.

fn
useSyncRefstesteddemo

Syncs the value of a source ref with multiple target refs

fn
useThrottleFntesteddemo

Throttle execution of a function — a thin reactive wrapper around `@robonen/stdlib`'s `throttle`. Invokes `fn` at most once per `delay` window and resolves with the wrapped function's result. Especially useful for rate-limiting handlers on high-frequency events like `scroll` and `resize`. Accepts either positional arguments or a single options object, and exposes `cancel`/`flush` controls on the returned function.

fn
useToNumbertesteddemo

Reactively convert a string or number ref to a number.

fn
useToStringtesteddemo

Reactively stringify a value, equivalent to `computed(() => String(toValue(value)))`.

Sensors · 50

I
BatteryManagertesteddemo

The `BatteryManager` interface of the Battery Status API.

T
GamepadEventHookOntesteddemo

Subscribe to a gamepad lifecycle event. Returns a stop function that removes the listener; it is also auto-removed when the owning scope is disposed.

fn
isFocusedElementEditabletesteddemo

Decides whether the currently focused element already swallows text input (an `<input>`, `<textarea>`, or any `contenteditable` host). When it does we leave the keystroke alone so we never steal focus from a real text field.

fn
isTypedCharValidtesteddemo

Returns `true` when the event represents a single printable character typed without a command/control/alt modifier. Uses `KeyboardEvent.key` (a single Unicode grapheme for printable keys) instead of the deprecated `keyCode`, so it transparently covers digits, latin letters and any other printable glyph.

fn
mapGamepadToXbox360Controllertesteddemo

Maps a raw {@link Gamepad} into a named Xbox 360 controller layout (buttons, bumpers, triggers, sticks, dpad). Returns `null` while no gamepad is present.

fn
onKeyDowntesteddemo

Listen for `keydown` strokes. Shorthand for `onKeyStroke` with `eventName: 'keydown'`.

fn
onKeyPressedtesteddemo

Listen for `keypress` strokes. Shorthand for `onKeyStroke` with `eventName: 'keypress'`.

fn
onKeyStroketesteddemo

Listen for keyboard strokes. Accepts a key, list of keys, or a predicate and fires the handler for matching events. Auto-cleans up on scope dispose. Overload 1: Explicit key filter

fn
onKeyUptesteddemo

Listen for `keyup` strokes. Shorthand for `onKeyStroke` with `eventName: 'keyup'`.

fn
onLongPresstesteddemo

Directive-like helper that invokes a handler after a sustained long press on a target element. Movement beyond `distanceThreshold` cancels the press, and an optional `onMouseUp` callback reports the press duration, distance, and long-press status. Listeners are passive by default and registered via `useEventListener` for automatic cleanup.

fn
onStartTypingtesteddemo

Fires the callback when the user starts typing on a non-editable element, ideal for auto-focusing a search box.

T
ParallaxAdjusttesteddemo

Adjusts a normalised (`-0.5 ~ 0.5`) parallax value before it is returned.

T
ParallaxSourcetesteddemo

Where the parallax `roll`/`tilt` values are currently being derived from.

I
ScreenOrientationtesteddemo

Subset of the `ScreenOrientation` interface that we interact with.

fn
useBatterytesteddemo

Reactive Battery Status API. Tracks the device charging state, charge level, and the estimated charging/discharging times, keeping them in sync with the underlying `BatteryManager` events.

fn
useBodyScrollLocktesteddemo

Reference-counted body scroll lock. Safe to invoke from multiple concurrent modals — the lock releases only after all holders release. Preserves the original overflow/padding/touch-action values and compensates for scrollbar removal to prevent layout shift.

fn
useClickOutsidetesteddemo

Invokes `handler` when a pointer event occurs outside `target`. SSR-safe: no-op on the server. Handles portaled/ignored subtrees and guards against synthetic "outside" clicks on removed nodes.

fn
useDeviceMotiontesteddemo

Reactive `DeviceMotionEvent` exposing acceleration (with and without gravity), rotation rate, and the hardware sampling interval. SSR-safe, uses a single passive listener, and supports the iOS 13+ permission flow.

fn
useDeviceOrientationtesteddemo

Reactive [`DeviceOrientationEvent`](https://developer.mozilla.org/en-US/docs/Web/API/DeviceOrientationEvent). Provides physical orientation of the device relative to Earth's coordinate frame.

fn
useDevicePixelRatiotesteddemo

Reactively track `window.devicePixelRatio`, updated via a `matchMedia(resolution)` listener (fires on zoom and on monitor changes).

fn
useDevicesListtesteddemo

Reactive `enumerateDevices` listing available media input/output devices.

fn
useElementByPointtesteddemo

Reactive element(s) at a given viewport point, sampled every animation frame via `document.elementFromPoint` (or `elementsFromPoint` when `multiple` is set).

fn
useElementHovertesteddemo

Reactive hover state of an element, driven by `mouseenter` / `mouseleave`. Supports independent enter/leave delays to debounce flicker.

fn
useEscapeKeytesteddemo

Register a callback for the topmost Escape keydown. Uses an internal stack so that nested layers (e.g. nested Dialogs) dismiss in the correct order — only the most recently-registered listener fires for a given keydown.

fn
useFocustesteddemo

Reactive focus state of an element. The returned `focused` ref tracks focus/blur events and can be written to in order to focus or blur the target.

fn
useFocusWithintesteddemo

Reactive tracking of whether an element or any of its descendants are focused, backed by the `focusin`/`focusout` events.

fn
useFpstesteddemo

Reactive FPS counter based on `requestAnimationFrame`. Reports a smoothed FPS value averaged over a configurable number of frames, and tracks min/max values.

fn
useGamepadtesteddemo

Reactive wrapper around the Gamepad API. Tracks connected gamepads, emits connection/disconnection events, and polls live button/axis state on every animation frame. The polling loop stays paused while no gamepad is connected and resumes automatically on the first connection, so there is zero idle work. SSR-safe.

fn
useGeolocationtesteddemo

Reactive Geolocation API. Watches the device position, exposing reactive coordinates, error, and readiness state, plus pause/resume controls and a one-shot `getCurrentPosition`.

fn
useIdletesteddemo

Track whether the user has been inactive for a given duration.

fn
useInfiniteScrolltesteddemo

Trigger a loader as a scroll container nears one of its edges. Backed by {@link useScroll} for RTL-aware arrived-edge detection: the `distance` is folded into that direction's offset, so `onLoadMore` fires the moment the edge comes within `distance` pixels. Re-checks automatically after each load (so an under-filled container keeps loading) and degrades safely under SSR and when `IntersectionObserver` is unavailable.

T
UseInfiniteScrollLoadMoretesteddemo

Result of the `onLoadMore` callback. May be synchronous or a promise; the loader is considered busy until it settles.

fn
useKeyModifiertesteddemo

Reactive state of a keyboard modifier (CapsLock, NumLock, Shift, Control, Alt, Meta, ...) tracked via `KeyboardEvent.getModifierState`.

fn
useMagicKeystesteddemo

Reactive keys pressed state, with magical combination keys support via a Proxy. Access combinations directly as properties, e.g. `keys['ctrl+a']` or `keys.ctrl_a`.

fn
useMousetesteddemo

Reactive mouse (and optionally touch) position with optional custom target, scroll tracking, custom extractors, and event filtering.

T
UseMouseEventExtractortesteddemo

Extracts an `[x, y]` pair from a mouse or touch point, or `null` to skip.

fn
useMouseInElementtesteddemo

Reactive mouse position relative to an element. Exposes the cursor position, the cursor position relative to the element's top-left corner, the element's position and size, and whether the cursor is outside the element. Element geometry is observed via `useElementBounding` (`ResizeObserver` + `MutationObserver` + window scroll/resize), so the relative coordinates stay correct as the element moves or resizes — without re-measuring the element on every pointer move.

fn
useMousePressedtesteddemo

Reactive mouse/touch/drag pressed state on a target, with the input source type and optional press/release callbacks.

fn
useNetworktesteddemo

Reactive Network Information API state plus online/offline status.

fn
useOnlinetesteddemo

Reactive online/offline status based on `navigator.onLine`. For connection details (effectiveType, downlink, saveData, transition timestamps, ...) use {@link useNetwork} instead.

fn
usePageLeavetesteddemo

Reactive flag indicating whether the mouse has left the page.

fn
useParallaxtesteddemo

Reactive parallax effect. Prefers the device orientation sensors and transparently falls back to mouse position when orientation is unavailable. Composes {@link useDeviceOrientation} and {@link useMouse}; pass a `target` to make the mouse fallback relative to an element's centre instead of the whole viewport. SSR-safe.

fn
usePointertesteddemo

Reactive pointer state (position, pressure, tilt, size, and pointer type) sourced from pointer events on a target, plus whether the pointer is currently inside it.

fn
usePointerLocktesteddemo

Reactive [Pointer Lock API](https://developer.mozilla.org/en-US/docs/Web/API/Pointer_Lock_API). Locks the mouse cursor to an element and tracks the locked element reactively.

fn
usePointerSwipetesteddemo

Detect swipe gestures via PointerEvents on a target element. Works for mouse, touch and pen with a single unified event model, tracking start/end coordinates, the active state and the resolved direction.

fn
useScreenOrientationtesteddemo

Reactive Screen Orientation API. Tracks the current orientation `type` and `angle`, and exposes helpers to lock/unlock the orientation. SSR-safe.

fn
useScrolltesteddemo

Reactive scroll position and state for an element or the window, with arrived-edge detection (RTL-aware), scroll directions, an `isScrolling` flag, optional throttling, and a `measure()` method for manual re-sync.

fn
useScrollLocktesteddemo

Lock scrolling of an element by toggling `overflow: hidden`, preserving the element's prior inline overflow and handling iOS `touchmove`. Returns a writable boolean ref — set it to lock/unlock, read it for state.

fn
useSwipetesteddemo

Detect swipe gestures via touch events on a target element. Tracks start/end coordinates, the active state and the resolved direction.

fn
useTextSelectiontesteddemo

Reactively track the user's text selection via `Window.getSelection`.

State · 16

fn
createSharedComposabletesteddemo

Promotes a composable to a shared one: every call reuses the same instance backed by a single effect scope. The scope is created lazily on the first consumer and is ref-counted, so it is disposed only when the last consumer's scope unmounts. State is recreated on the next call after a full dispose.

fn
useAppSharedStatetesteddemo

Provides a shared state object for use across Vue instances

fn
useAsyncStatetesteddemo

A composable that provides a state for async operations without setup blocking

fn
useContextFactorytesteddemo

A composable that provides a factory for creating context with unique key

fn
useCountertesteddemo

A composable that provides a counter with increment, decrement, set, get, and reset functions

fn
useCycleListtesteddemo

Cycle through a list of items, with `next`/`prev`/`shift`/`go` controls. Supports a reactive list — the index is kept valid when the list changes.

fn
useDebouncedRefHistorytesteddemo

Track the change history of a ref, debouncing commits so that rapid bursts of changes collapse into a single history record. A shorthand for {@link useRefHistory} pre-wired with a debounce {@link EventFilter}.

fn
useIdtesteddemo

SSR-safe unique identifier. Thin wrapper around Vue 3.5's built-in `useId()` that accepts an optional prefix and allows callers to pass a pre-existing id (useful for primitives that accept a user-supplied `id` prop).

fn
useInjectionStoretesteddemo

Create a global state that can be injected into components

fn
useLastChangedtesteddemo

Records the last time a value changed

fn
useManualRefHistorytesteddemo

Manually-committed undo/redo history for a ref. Records snapshots only when `commit()` is called, with optional cloning, serialization, and a bounded capacity.

fn
useOffsetPaginationtesteddemo

A composable function that provides pagination functionality for offset based pagination

fn
useRefHistorytesteddemo

Track the change history of a ref with undo/redo, pause/resume, batching, and manual commits.

fn
useSteppertesteddemo

A composable for building wizards/steppers over a list or record of steps

fn
useThrottledRefHistorytesteddemo

Shorthand for {@link useRefHistory} with a throttled event filter, so rapid source changes are committed at most once per interval (trailing edge by default).

fn
useToggletesteddemo

A composable that provides a boolean toggle with customizable truthy/falsy values

Storage · 6

Types · 14

T
MaybeComputedRefArgs

Argument form accepted by the reactive math helpers (`useMax`, `useMin`, `useSum`, `useAverage`): either a spread of (possibly reactive) values, or a single (possibly reactive) array of them.

T
RemovableRef

A ref that can be set to `null` to remove the associated storage entry. Setting the value to `null` or `undefined` will call `removeItem` on the storage backend.

I
ResumableActions

The actions for a resumable process.

I
ResumableOptions

Often times, we want to pause and resume a process. This is a common pattern in reactive programming. This interface defines the options and actions for a resumable process.

I
StandardSchemaFailureResult

A failed validation result.

T
StandardSchemaInferInput

Infer the input type of a Standard Schema.

T
StandardSchemaInferOutput

Infer the output type of a Standard Schema.

I
StandardSchemaIssue

A single validation issue.

I
StandardSchemaPathSegment

A single segment of an issue path.

I
StandardSchemaProps

The properties carried on a schema's `~standard` key.

T
StandardSchemaResult

The result of validating a value: either a success carrying the typed output or a failure carrying a list of issues.

I
StandardSchemaSuccessResult

A successful validation result.

I
StandardSchemaTypes

The inferred input/output types of a schema.

I
StandardSchemaV1

Vendored, dependency-free types for the [Standard Schema](https://github.com/standard-schema/standard-schema) spec (v1). Any validation library implementing the `~standard` contract — zod, valibot, arktype, … — is structurally assignable to {@link StandardSchemaV1}, so the forms layer can accept them without taking on a dependency. The namespace pattern from the official spec is flattened into named exports to stay within the repo's lint rules.

Utilities · 17

fn
createEventHooktesteddemo

Lightweight, non-reactive event hook factory exposing `{ on, off, trigger, clear }`. `on` returns a callable off handle (also carrying an `.off` method) and auto-removes the listener on scope dispose. `trigger` awaits async listeners and resolves with all their results. SSR-safe (touches no browser globals) and tree-shakeable.

T
EventBusIdentifiertesteddemo

Anything usable to identify a shared bus. Buses with an equal identifier share their listener set, regardless of how many times `useEventBus` runs.

I
EventBusKeytesteddemo

A branded `Symbol` that carries the bus' event type so a typed key can be shared across modules without re-declaring generics at every call site.

T
EventBusListenertesteddemo

A listener invoked when its bus emits. Receives the emitted `event` value and an optional `payload`.

T
EventHookListenertesteddemo

A listener for an event hook. `T` is the payload type: - `void` -> the listener takes no arguments - a tuple `[a, b]` -> the listener takes those positional arguments - anything else -> the listener takes a single argument of that type Listeners may be sync or async; async listeners are awaited by `trigger`.

I
EventHookOffHandletesteddemo

Handle returned from {@link EventHook.on}. It is both a callable that removes the listener and an object exposing an `off` method, so either of these work: ```ts const off = on(fn); off(); const { off } = on(fn); off(); ```

fn
gettesteddemo

Shorthand accessor that unwraps a ref/getter to its value, optionally reading a single property off the resolved value. Accepts plain values, refs and getter functions (via `toValue`), so it works anywhere `unref`/`toValue` would. Purely synchronous and side-effect free, so it is fully SSR-safe.

fn
isDefinedtesteddemo

Type-guard that checks whether a ref's (or plain value's) current value is neither `null` nor `undefined`, narrowing the source to its `NonNullable` form. Unwraps refs with a single `unref` — no extra reactivity or watchers are created, so it is a cheap synchronous check that is fully SSR-safe. For a reactive guard that tracks changes, use {@link useIsDefined}.

T
IsDefinedReturntesteddemo

The result of {@link isDefined}: a plain boolean acting as a type guard.

T
MemoizeCacheKeytesteddemo

The type of the key used to index the cache. Defaults to a serialized string but may be any value when a custom `getKey` is supplied.

fn
settesteddemo

Shorthand setter that mirrors {@link get}. Either assigns `value` to a ref (`ref.value = value`) or assigns `value` to a single property of an object (`target[key] = value`). The arity is resolved at the type level via overloads, so both forms stay fully type-safe. Purely synchronous and side-effect free, so it is fully SSR-safe.

fn
useEventBustesteddemo

A typed, SSR-safe event bus. Calls sharing an identifier share listeners, giving cross-component (and cross-module) communication without prop drilling or provide/inject. Backed by stdlib `PubSub` for stable snapshot-based emit semantics, and auto-removes the current scope's listeners on dispose so components never leak subscriptions.

fn
useIsDefinedtesteddemo

Reactive counterpart to {@link isDefined}. Returns a `ComputedRef<boolean>` that re-evaluates whenever the source ref, getter, or plain value resolves to a non-nullish value. Use this when the definedness itself needs to drive reactivity (templates, watchers, derived state); reach for the synchronous {@link isDefined} when you only need a one-off type guard.

T
UseIsDefinedReturntesteddemo

The result of {@link useIsDefined}: a readonly computed boolean.

fn
useMemoizetesteddemo

Cache the result of a (possibly async) function by its arguments, exposing a reactive cache and explicit `load`/`delete`/`clear`/`generateKey` controls. When no custom `cache` is supplied the default `Map` path delegates to `@robonen/stdlib`'s `memoize` for the get-or-compute core and is wrapped in `shallowReactive` so cache reads inside effects stay live. A custom cache backend (e.g. an LRU) can be plugged in via `options.cache`. SSR-safe: no browser globals are touched.

I
UseMemoizeCachetesteddemo

Pluggable cache backend. Any object implementing this shape can be supplied via `options.cache` to control storage (e.g. an LRU cache). When omitted a plain `Map` is used and the heavy lifting is delegated to `@robonen/stdlib`'s `memoize`.

fn
useSupportedtesteddemo

SSR-friendly way to check if a feature is supported

Utils · 6

Watch · 7