Data

resource()#

one primitive for async data: resource(url), resource(() => url), resource({ params, loader }), resource(url, { cache: true, staleTime }) (SWR, shared by key, keepPrevious), resource(url, { offline: true }) (IndexedDB + mutation queue). One result shape: data, loading (first load), validating (refetch over data), stale, status, error, refresh(), mutate(), abort(), ready(). Structural sharing keeps row identity on refetch, retry with backoff, refetch: { focus, reconnect, interval } opt-in

mutation()#

pending, double-submit guard, optimistic update + rollback, invalidates

streamResource() / sse()#

NDJSON/text streaming into a growing signal; Server-Sent Events writing straight into signals

configure({ csrf: 'django' })#

CSRF presets (django/rails/laravel/go), default headers, baseURL, timeout; request()/api.get|post|… send JSON, add the token, throw HttpError with the parsed body; defaults.fetcher is the single mocking point

prefetch() / prefetchOn(el, url, { on: 'hover' })#

warm the cache on hover/tap/visible; infiniteResource() for cursor pagination

settled()#

await every in-flight request in tests instead of sleep(50)

resource(url, { cache: true })#

the SWR cache; invalidate() revalidates live resources immediately, revalidateOn: ['focus', 'reconnect'] by default

seed() / seedFrom()#

zero-fetch hydration: the server inlines data, the island renders without a request

<script type="application/json" data-aegis-cache="/api/users?page=1" data-aegis-age="120">[…]</script>
<div data-aegis="users" data-url="/api/users?page=1"></div>

hydrate() seeds the cache first, so resource(data.url, { cache: true, staleTime: 30_000 }) inside the island has its data immediately. seed(key, data) also puts a mutation response straight into the cache.

resource(url, { offline: true })#

IndexedDB cache, one mutation queue per app flushed on reconnect with retry/backoff and Background Sync, send() for network writes

Edit this page on GitHub