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";
APIPurposeLearn 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";
ExportPurposeLearn 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";
TypeUse it for
IslandA renderable/mountable island value.
KeyedIslandA registry entry with a stable hydration key.
HydratableOptionsOptions accepted by .hydratable().
IslandStateState accessors passed to render/handlers/effects.
IslandDerivedDerived accessors passed to render/handlers/effects.
HandlerContextEvent handler context.
EffectContextReactive effect context.
OnMountContextMount hook context.
ErrorContextError handler context.
ErrorSourceWhere an error originated: "on", "effect", "mount", or "transition".
PackageGuide
@ilha/routerRouter
@ilha/storeStore