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

@affordances/react

Affordances for React. <AffordancesProvider> loads the current page's graph and registers each available action as a WebMCP tool for browser agents; the tools call the page's Affordances endpoint, so they pass the same checks as any agent. <Affordance> marks the controls a person would use for an action, for agents that read the DOM. <AffordancesDevtools> from @affordances/react/dev outlines them in development.

Terminal
vlt install @affordances/react
TSX
'use client'

import { usePathname, useRouter } from 'next/navigation'
import { AffordancesProvider } from '@affordances/react'

export const Agents = ({ children }: { children: React.ReactNode }) => {
  const pathname = usePathname()
  const router = useRouter()
  return (
    <AffordancesProvider path={pathname} onDelta={() => router.refresh()}>
      {children}
    </AffordancesProvider>
  )
}

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


PreviousReferenceNext@affordances/react

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