Documentation.Find it fast.

Search by keyword or browse by category. All links go to pages on this site.

Data Loading

5

Loaders — data fetching pipeline

Loader.succeed, fail, map, map2, andThen, redirect (auth guard shortcut). Loader.requireUser decodes session cookie and redirects unauthenticated requests. Loader.redirect sends a 302 without running an Action. Loader.custom for escape hatch to custom TypeScript effects. Loader.fetchJson, cacheGet, cachePut, env, getCookie, enqueue, session, csrfToken, startJob, jobStatus. page : Request -> Loader (Document msg) contract.

SQL Effects — query, execute, soft writes, transactions

Loader.query (list), Loader.queryOne (Maybe). Loader.execute { sql, params } returns { rowsAffected }. Loader.softExecute and Loader.softQueryOne return Ok / Err ConstraintError instead of failing. Loader.transaction wraps multi-statement writes atomically — rollback on any failure. Requires sqlTransaction configured on adapter.

Cache & HTTP Effects

Loader.fetchJson { url, decoder } — HTTP GET. Loader.cacheGet { key, decoder } returns Maybe (null on miss). Loader.cachePut { key, value, ttlSeconds? }. Backend-neutral: withCache wraps any runner, redisCache(redis) or cloudflareEffects (KV). Pattern: cacheGet → fetchJson on miss → cachePut.

Effects Vocabulary — every effect kind

Flat table of all Loader effect kinds and which adapter handles them: fetchJson, cacheGet, cachePut, query, queryOne, execute, softExecute, softQueryOne, transaction, env, cookie, enqueue, session, csrfToken, setSession, clearSession, startJob, jobStatus, custom. Which effects need sessionMiddleware. Failure shape { ok, error }. Adapter composition order.

Loader.custom — escape hatch for your own effects

Loader.custom { kind, payload, decoder }. Define a custom effect kind handled in TypeScript adapter. Used for fan-out Promise.all, AI / vector / search calls, third-party APIs, service aggregations. Your handler receives payload, returns { ok, value } or { ok: false, error }.