API reference

API reference

Everything the packages export, grouped by what you use it for. @velozjs/dom and @velozjs/ssr re-export the reactive API, so most apps import from one package.

Reactivity

FunctionDescription
createSignal(value, options?)[get, set]. options.equals: comparison or false to always notify.
createMemo(fn, initial?, options?)Cached derived value; notifies only when the result changes.
createEffect(fn, initial?)Runs now and whenever what it read changes; receives the previous return value.
createRenderEffect(fn, initial?)Same scheduling as createEffect; used for DOM updates.
batch(fn)Runs fn and flushes effects once at the end; returns fn's result.
untrack(fn)Reads signals in fn without subscribing.
on(deps, fn, { defer }?)Explicit dependencies (a getter or an array); fn runs untracked.
createRoot(fn)A scope not disposed with its parent; fn receives dispose.
onCleanup(fn)Runs before the owner re-runs and when it is disposed.
onMount(fn)Runs once after the component is created, inside its owner.
catchError(fn, handler)Sends errors from fn and from computations created in it to handler.
createContext(default?) / useContext(ctx)Dependency injection through the owner tree.
access(value)Calls value if it is a function (for MaybeAccessor<T> props).
getCurrentOwner() / runWithOwner(owner, fn)Low-level access to ownership.

Async

FunctionDescription
createResource(fetcher, options?)Async value; fetches once.
createResource(source, fetcher, options?)Fetches when source is set and whenever it changes.
resource()Value, or throws the last error.
resource.state / .loading / .error / .latestReactive status.
{ mutate, refetch }Set the value locally; load again.
options.initialValue / options.nameStart ready with a value; stable key for SSR hand-off.

Rendering (@velozjs/dom)

ExportDescription
render(fn, container)Renders into container, replacing its content; returns a disposer.
hydrate(fn, container)Attaches to server-rendered HTML in container; returns a disposer.
createElement(tag, props, ...children)JSX without a compiler.
Fragment<>…</>
toNodes(value)Resolves anything renderable into DOM nodes.
sanitize(html, options?)Allowlist HTML sanitizer (allowedTags, allowedAttrs).
sanitizeURL(url) / validateAttribute(name, value)The URL and attribute checks used by the renderer.

Components

ComponentProps
Showwhen, fallback?, children (nodes or (value) => nodes)
Foreach, fallback?, children: (item, index) => nodes
Switch / MatchSwitch: fallback?; Match: when, children
ErrorBoundaryfallback (nodes or (error, reset) => nodes), children
Suspensefallback?, children
Portalmount? (default document.body), children
Dynamiccomponent (tag name or component), other props passed through

Styles (@velozjs/css)

ExportDescription
css`…`Scoped class name from a CSS block.
styled(tag)`…`Component with styles; interpolations receive props.
css={{…}} propEnabled by importing @velozjs/css.
getSSRStyles()Styles collected on the server (also returned by renderToString).

Server (@velozjs/ssr)

ExportDescription
renderToString(fn){ html, css }, synchronous.
renderToStringAsync(fn, options?){ html, css, data, script } after the data loads.
renderToStream(fn)ReadableStream<Uint8Array> with styles first.
serializeData(data)The escaped JSON used by the data script.
escapeHTML(s) / escapeAttr(s)Escaping helpers.

Vite plugin

ts
import veloz from 'vite-plugin-veloz';

veloz({ exclude: ['my-ui-kit'] });

exclude: packages whose imports of @velozjs/dom should not be redirected during SSR.