Live demo: Try the hosted example at 21st-sdk-nia-chat.vercel.app before setting up locally.
How it works
1
User enters a GitHub repo
The app normalizes the input and indexes the repository via the Nia API (
/api/nia/source).2
Sandbox + thread created
A sandboxed agent environment is created with Nia skill scripts baked in (
/api/agent/sandbox).3
Chat streams responses
The frontend connects to the agent using
createAgentChat + useChat and streams answers grounded in the indexed codebase.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
Building something similar
The core pattern for building an agent-powered app with Nia knowledge:1
Define your agent
Use
@21st-sdk/agent to set the model, system prompt, and any tools/skills to include in the template directory.2
Deploy the sandbox
Run
npx @21st-sdk/cli deploy to bake the template into the sandbox image.3
Create API routes
Set up sandbox/thread management with
AgentClient and a token endpoint with createTokenHandler.4
Connect the frontend
Use
createAgentChat() bound to a sandbox + thread, then pass it to useChat() from @ai-sdk/react for streaming.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

