ilha
Maps public ilha exports to the guide pages that explain them in depth. For narrative tutorials, use Introduction and the island API sections first.
Builder chain
Start every island with the default export:
import ilha from "ilha";
| API | Purpose | Learn more |
|---|---|---|
ilha.input<T>() / ilha.input(schema) | Define typed or validated props. | Input |
.state(key, initial?) | Add local island state. | State |
.derived(key, fn) | Add computed or async derived state. | Derived |
.on(selector, handler) | Add delegated event handlers. | On |
.effect(fn) | Run reactive side effects. | Effect |
.onMount(fn) | Run mount-only client effects. | On Mount |
.onError(fn) | Per-island error handler. | On Error |
.transition(options) | Enter/leave animations on mount and unmount. | Transition |
.css(styles) | Attach scoped styles. | CSS |
.render(fn) | Produce an island from JSX/HTML. | Render |
.hydratable(options?) | Mark an island for SSR hydration. | Hydratable |
Helpers from ilha
import {
mount,
html,
raw,
css,
signal,
context,
batch,
untrack,
from,
onUncaughtError,
} from "ilha";
| Export | Purpose | Learn more |
|---|---|---|
onUncaughtError(fn) | App-wide error sink when islands lack .onError(). | On Error |
mount(registry, options?) | Mount islands in the browser. | Mount |
html\...`` | Create escaped HTML template output. | HTML |
raw(value) | Mark trusted HTML as unescaped. | Raw |
css\...`` | Create CSS template output. | CSS helper |
signal(initial) | Create a shared reactive accessor. | Signals |
context(key, initial) | Create a keyed shared signal. | Signals |
batch(fn) | Batch multiple writes into one update. | Signals |
untrack(fn) | Read signals without tracking dependencies. | Signals |
from(source) | Adapt external signal-like values for Ilha. | Signals |
JSX runtime
Use the automatic runtime with a pragma or tsconfig.json:
/** @jsxImportSource ilha */
{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "ilha"
}
}
Build tools will resolve ilha/jsx-runtime in production and ilha/jsx-dev-runtime in development.
Common public types
import type {
Island,
KeyedIsland,
HydratableOptions,
IslandState,
IslandDerived,
HandlerContext,
EffectContext,
OnMountContext,
ErrorContext,
ErrorSource,
} from "ilha";
| Type | Use it for |
|---|---|
Island | A renderable/mountable island value. |
KeyedIsland | A registry entry with a stable hydration key. |
HydratableOptions | Options accepted by .hydratable(). |
IslandState | State accessors passed to render/handlers/effects. |
IslandDerived | Derived accessors passed to render/handlers/effects. |
HandlerContext | Event handler context. |
EffectContext | Reactive effect context. |
OnMountContext | Mount hook context. |
ErrorContext | Error handler context. |
ErrorSource | Where an error originated: "on", "effect", "mount", or "transition". |
Related packages
| Package | Guide |
|---|---|
@ilha/router | Router |
@ilha/store | Store |