Complete examples

Every experimental-a2 install includes a complete Next.js playground to copy, run, and read.

Shipped with the package

cp -R node_modules/experimental-a2/examples/playground ./a2-playground
cd a2-playground
pnpm install
pnpm dev

The playground lives at node_modules/experimental-a2/examples/playground. Each feature owns its contract, reducer, server, route handlers, client session, and scheduler when it needs one, using only public entry points.

The copy is standalone: its package.json pins A2 to the version that shipped it, and its AGENTS.md describes the structure to coding agents that work inside the directory.

Find the right example

  • app/counter is the smallest complete contract, reducer, server, and React client.
  • app/orders adds handlers and a feature-owned scheduler.
  • app/chat shows request-scoped authorization and durable AI generation.
  • app/agent shows tools, approvals, reminders, and sandboxed commands.
  • app/canvas adds optimistic state, presence, and WebSocket upgrades.
  • app/documents combines A2 events with a collaborative document protocol.
  • app/recovery demonstrates queue recovery across function invocations.

Guidance for coding agents

When A2 is installed locally, read these package directories in this order:

  1. node_modules/experimental-a2/docs for the supported API and guarantees.
  2. node_modules/experimental-a2/examples/playground for complete application structure.
  3. node_modules/experimental-a2/src only when implementation details are relevant.

Don't infer application patterns from dist. The playground, generated from apps/playground in the A2 repository at publish time, is the reference for how the public pieces fit together.