Build one React AI interface in four layers: streaming, tools, typed React UI, and production-ready interaction patterns.
The repository root is the workshop starter. The completed reference is in steps/04-production/.
Requires Node.js 20.9+ and pnpm.
git clone https://github.com/aurorascharff/ai-react-workshop.git
cd ai-react-workshop
pnpm install
pnpm devOpen http://localhost:3000.
Keep the repository root open while you work:
- Open the current file in exercises/. It describes the problem, the outcome, and the few files you need to change.
- Try the exercise in the root app.
- If you get stuck or want to compare approaches, open the matching reference solution in exercises/solutions/. It contains the exact code and explains why it works.
- The apps in steps/ are runnable checkpoints after each exercise. They do not apply changes to your app. Use them to compare behavior, catch up, or demo the finished state while you keep editing the root app.
Visual components, mock data, request validation, persistence, and safe error helpers are provided. The exercises stay focused on the React and AI SDK decisions being taught.
The workshop works without a key by using its built-in mock assistant. To use OpenAI instead:
-
Create a key in the OpenAI API Keys dashboard.
-
Create
.env.local:OPENAI_API_KEY=your_key_here OPENAI_MODEL=gpt-5.6-terra
-
Restart
pnpm dev.
API billing is separate from ChatGPT. Add credits or check spend limits in the OpenAI billing overview. Never commit .env.local.
Mock mode can also be selected explicitly:
MOCK_AI=1 # Always use the mock assistant
MOCK_AI=0 # Require the live API| Module | What we build | Exercise |
|---|---|---|
| 1 | Stream text as it arrives | Stream AI responses |
| 2 | Give the model typed server-side tools | Give the model tools |
| 3 | Render streamed tool states with React components | Render results as React UI |
| 4 | Add cancellation, persistence, and error paths | Make it production-ready |
The exercise is the assignment. The reference solution is the detailed answer. The checkpoint is the runnable result.
The small agent/ directory is inspired by Eve, where an agent grows from focused instructions into optional configuration, tools, and skills:
agent/
├── agent.ts model and provider configuration
├── instructions.ts always-on behavior and safety rules
├── tools/ narrow server-side capabilities
└── skills/ reusable workflows loaded when relevant
Exercise Two adds the tools and the release-readiness skill. This workshop uses AI SDK directly rather than Eve, but keeps the same separation so the route does not become one large file. The data functions under lib/ stand in for authenticated application services that tools would call in a real product.
Each checkpoint is a standalone Next.js app that shares the dependencies installed at the repository root. Enter the checkpoint you want to inspect, then run it normally:
cd steps/04-production
pnpm devThe same command works inside 00-starter, 01-streaming, 02-tools, and 03-generative-ui. Stop the current server before switching checkpoints. To compare a checkpoint beside your work, give it another port:
pnpm dev --port 3001The snapshots run independently from 00-starter through 04-production. Install dependencies once at the repository root. Every checkpoint reads the repository root .env.local; none of them modifies the starter you are editing.
pnpm dev
pnpm check
pnpm build
pnpm build:stepspnpm check includes every checkpoint typecheck. Run pnpm build:steps before hosting to build all five standalone apps.
The instructor schedule and module notes are in WORKSHOP.md.