vlt / affordances
  • Quickstart
  • Concepts
  • Guides
  • Reference
  • Overview
  • Getting started
  • Files and conventions
  • Routing
  • Route handlers
  • Plugins
  • Sessions
  • What's left alone
  • Discovery
  • Caching
  1. Guides
  2. /
  3. Next.js
  4. /
  5. Routing

Routing

How the same URL answers people with HTML and agents with a graph, how agents discover it, and why graphs are never cached.

The same URL answers people and agents. withAffordances adds rewrites that run before Next's filesystem routes, and send a request to the route handler when it has any of:

  • Accept: application/vnd.affordances+json (reading a graph);
  • Content-Type: application/vnd.affordances+json (calling an action);
  • the query parameter affordances=1, for clients that can't set headers.

/.well-known/affordances.json, the site index, is rewritten to the handler too.

What's left alone

  • Every browser request for HTML reaches your pages as before.
  • Requests to /api/ routes, the handler's own included, and to /_next are never rewritten.
  • Your own rewrites are kept. withAffordances puts its rules first in beforeFiles and leaves the rest where they were.

Discovery

For each route in the manifest, withAffordances adds a header to the HTML response, so a client that loaded the page can find its graph:

http
Link: <?affordances=1>; rel="affordances"

Caching

Graphs and deltas are sent with Cache-Control: private, no-store and Vary: Accept. HTML responses keep whatever caching they had.

Agent requests are rewritten to the handler before the filesystem and before any cached page. So a cached HTML page is never served to an agent, and a graph is never cached at all.


PreviousFiles and conventionsNextRoute handlers

On this page

  • What's left alone
  • Discovery
  • Caching
Edit this page

Make your app agent-operable

Give every page a graph and every server action an agent path: HTTP, WebMCP, and MCP, with the same session and the same checks. One command sets it up.

Read the quickstart