Live demo: Try the hosted example at 21st-sdk-nia-chat.vercel.app before setting up locally.
How it works
User enters a GitHub repo
The app normalizes the input and indexes the repository via the Nia API (
/api/nia/source).Sandbox + thread created
A sandboxed agent environment is created with Nia skill scripts baked in (
/api/agent/sandbox).Features
Repository Analysis
Index any public GitHub repo and ask questions about its architecture, patterns, and implementation details.
Codebase Chat
Natural language conversation grounded in the full repository — not just file summaries.
Sandboxed Agents
Each agent runs in an isolated sandbox with Nia tools pre-installed via the 21st Agents SDK.
Multi-thread Sessions
Create multiple conversation threads per sandbox, persisted in
localStorage.Stack
Next.js
App Router with API routes for agent management.
21st Agents SDK
Agent definition, deployment, and frontend streaming.
Nia MCP
Knowledge tools for search, read, explore, and grep.
Requirements
- Node.js 18+
API_KEY_21ST— from 21st.devNIA_API_KEY— from app.trynia.ai- deployed
nia-agent-v2
NIA_API_KEY must exist both in .env.local (for the Next.js server to resolve/index repos) and in the deployed sandbox environment (for the Nia skill scripts).Quick start
Clone the repo and install dependencies:API_KEY_21ST and NIA_API_KEY in .env.local, then deploy the agent and start the dev server:
Key files
| File | What it does |
|---|---|
agents/nia-agent-v2/index.ts | Agent definition — model, system prompt, sandbox setup. Uses @21st-sdk/agent. |
agents/nia-agent-v2/template/.claude/skills/nia/ | Nia skill scripts baked into the sandbox. Shell wrappers for search, read, explore, etc. |
app/api/nia/source/route.ts | Normalizes the repo input, then resolves (or indexes) it via the Nia SDK. |
app/api/agent/sandbox/route.ts | Creates a sandbox + thread via AgentClient from @21st-sdk/node. |
app/api/agent/token/route.ts | Token endpoint using createTokenHandler from @21st-sdk/nextjs/server. |
app/api/agent/threads/route.ts | Lists/creates threads within a sandbox for multi-thread sessions. |
app/page.tsx | Main UI — repo picker, chat panel, thread sidebar. |
Building something similar
The core pattern for building an agent-powered app with Nia knowledge:Define your agent
Use
@21st-sdk/agent to set the model, system prompt, and any tools/skills to include in the template directory.Create API routes
Set up sandbox/thread management with
AgentClient and a token endpoint with createTokenHandler.Links
GitHub
View the source code on GitHub
Live Demo
Try the hosted example
21st.dev
Learn more about the 21st Agents SDK
Nia Skill Scripts
How Nia skill scripts work

