Skip to content

ui-router-server / fetch / FetchAdapterOptions

Interface: FetchAdapterOptions<Args, Decls> ​

Defined in: fetch.ts:205

Host hooks for createFetchHandler: asset IO, which requests get verdicts, delegate handlers, and response states.

Type Parameters ​

Type ParameterDefault type
Args extends unknown[][]
Decls extends RouteDeclarationRouteDeclaration

Properties ​

PropertyTypeDescriptionDefined in
base?stringThe url path the site is served at, / by default. The handler matches each request with the base taken off, so the mount table stays at /, returns null for a request outside the base, and puts the base back on redirect Locations, the canonical Link and the shell Request's url. Delegates and serveResponse get the original request. Defaults to the router's base; a different value throws. Under a base the router doesn't declare, the handler resolves the base once and every request rejects when a mount already carries it.fetch.ts:219
delegates?DelegateHandlers<Args, Decls>Handlers for the keys states name in `delegate`. A request of any method or Accept that matches a delegating state goes to its handler, called with the original request and the arguments the adapter got (delegates: { ledger: app.fetch }), so every handler shares one Args signature. A typed router requires every key it names at compile time; construction throws when a router from createServerRouter names a key missing here. A structural router is checked per request instead, so its delegate verdict throws. Requests outside shouldHandle only match urls, never a transition, and pass as null without matching when the router names no keys (or, for a structural router, when this option is absent).fetch.ts:270
serveNotFound?(mount, request) => | Response | Promise<Response>Serve a mount-owned miss (notFound with a mount: the mount owned the pathname but no route matched). The default answers a minimal text/plain 404 — override to serve a real 404 page. A notFound without a mount is never routed here: the pathname isn't this router's, so the handler returns null and the host serves it.fetch.ts:243
serveResponse?ServeResponse<Args>Answers the states marked `response`. A GET or HEAD of any Accept that matches one comes here, so an <img> reaches its badge; other methods get a 405. A typed router that declares response states requires it at compile time; construction throws when a router from createServerRouter declares one and it is absent. A structural router's response verdict throws per request instead.fetch.ts:279
serveShell(mount, request) => | Response | Promise<Response>Serve the mount's shell asset. The adapter hands over a shell Request already rewritten to shellPath and, for a status'd shell, already stripped of conditional validators — so the host returns the RAW asset Response ((mount, request) => env.ASSETS.fetch(request)) and the adapter owns the status relabel and Link header on the way out. REQUIRED: asset IO is the one thing a runtime-neutral adapter cannot default.fetch.ts:235
shellPath?(mount) => stringMaps a shell verdict's mount to the pathname the shell Request is built at (default: the mount base itself). The hook for aliased mounts whose shell asset lives under another prefix (e.g. a 404 exhibit that borrows the vanilla app's shell).fetch.ts:226
shouldHandle?(request) => booleanWhich requests get verdicts. The default is the navigation heuristic the Connect adapter uses (and Vite's HTML fallback mirrors): GET/HEAD requests whose Accept includes text/html. Module and asset fetches (Accept: *​/*) pass as null. Override with () => true when the handler runs behind the static layer and should judge everything. Delegating states ignore it: they answer every request that matches them.fetch.ts:255