JSX Runtime
Framework-native JSX and hooks, with no React dependency.
Updated: 2026-07-26
Configuration
Point jsxImportSource at @rigbyhost/karui in tsconfig, and in the Vite esbuild config for the bundler.
{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "@rigbyhost/karui"
}
}Hooks
The runtime provides useState, useEffect, useMemo, useCallback, useReducer, useRef, createContext, and useContext, with React semantics.
import { useState } from '@rigbyhost/karui/jsx';
export function Counter() {
const [count, setCount] = useState(0);
return <button onClick={() => setCount((c) => c + 1)}>{count}</button>;
}Refs
Pass a useRef to the ref prop of a host element. It is set when the element mounts and reset to null when it leaves the tree. A callback ref works too.
import { useEffect, useRef } from '@rigbyhost/karui/jsx';
export function SearchBox() {
const input = useRef<HTMLInputElement | null>(null);
useEffect(() => input.current?.focus(), []);
return <input ref={input} />;
}Attributes
className and htmlFor map to class and for. Style accepts a string or an object, and object styles are diffed per property. SVG children render in the SVG namespace automatically, with camelCase presentation attributes converted to kebab-case.
On form elements, value, checked, and selected are written as DOM properties and re-synced on every render, so a controlled field stays in step with its prop even after the user types.