vlt / affordances
  • Quickstart
  • Concepts
  • Guides
  • Reference
  • Overview
  • Getting started
  • Files and conventions
  • Routing
  • Route handlers
  • Plugins
  • Sessions
  • The manifest
  • What fails the build
  1. Guides
  2. /
  3. Next.js
  4. /
  5. Files and conventions

Files and conventions

Where state.ts and actions.ts go, how they map to routes, and what codegen checks before it writes the manifest.

Put state.ts and actions.ts next to the page.tsx they describe:

Text
app/
  page.tsx
  state.ts            → /
  actions.ts          → /
  (shop)/products/[slug]/
    page.tsx
    state.ts          → /products/[slug]
    actions.ts        → /products/[slug]
  api/affordances/graph/[[...path]]/
    route.ts          (the route handler)
  • Route groups like (shop) and parallel slots like @modal don't appear in the route.
  • Folders starting with _ are skipped.
  • A route can have state without actions, or actions without state.
  • Dynamic segments work as they do in Next: [slug], [...slug], and [[...slug]].

The manifest

Codegen reads these files statically, without running them, and writes .affordances/manifest.ts. It imports each route's state and actions, and the route handler reads it.

It's regenerated:

  • whenever Next loads the config (withAffordances runs it);
  • in next dev, whenever an actions or state file changes;
  • when you run affordances build, for scripts and CI.

Commit it or not, as you like. affordances init adds .affordances to .gitignore.

What fails the build

Codegen stops with an error when:

  • an actions file doesn't start with 'use server';
  • a defineAction call's name isn't a string literal;
  • two actions on one route share a name;
  • a state file has no default export.

The lint rules catch the first two in your editor.


PreviousGetting startedNextRouting

On this page

  • The manifest
  • What fails the build
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