vlt / affordances
  • Quickstart
  • Concepts
  • Guides
  • Reference
  • Overview
    • Overview
    • Reference
  1. Reference
  2. /
  3. API reference
  4. /
  5. @affordances/core

@affordances/core

The framework-agnostic core of Affordances: defineAction and defineState (or createAffordances for a shared session resolver), and createHandler, which answers graph and call requests as a (request: Request) => Promise<Response>. Framework adapters such as @affordances/next build on it.

Terminal
vlt install @affordances/core zod
TypeScript
import { z } from 'zod'
import { createHandler, defineAction, defineState } from '@affordances/core'

const guestbook = defineState(async () => ({ entries: await entries.list() }))

const sign = defineAction({
  name: 'sign',
  description: 'Add a message to the guestbook',
  input: z.object({ name: z.string().min(1), message: z.string().max(280) }),
  state: guestbook,
  expose: 'public',
  effects: ['entries'],
  run: (input) => entries.add(input),
})

export const handler = createHandler({
  manifest: { routes: { '/guestbook': { state: guestbook, actions: [sign] } } },
})

Docs: https://github.com/vltpkg/affordances/blob/main/apps/docs/content/concepts/actions.mdx


PreviousAPI referenceNextReference

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