Overview
Build AI applications with Civic Nexus and Vercel AI SDK v5. Your AI agents can access external tools and services through MCP (Model Context Protocol) - interact with GitHub, Slack, Dropbox, and more.Framework: This guide is written for Next.js projects. The core MCP client setup works with any JavaScript framework, but authentication setup uses Next.js-specific APIs.
Quick Start
The fastest way to get started is with our starter template:AI Chatbot Starter
Clone our Next.js + Vercel AI SDK template with Nexus pre-configured. Includes authentication, streaming, and tool calling out of the box.
Required Environment Variables
Required Environment Variables
Updated for AI SDK v5: This guide uses Vercel AI SDK v5 with
convertToCoreMessages()
for message handling and toUIMessageStreamResponse()
for streaming compatibility with @ai-sdk/react
.Build From Scratch
Want to integrate Nexus into an existing Next.js project? Follow the guide below.Prerequisites:
- Next.js 14+ project with App Router (Pages Router also supported)
- Civic account - Create account
- Connect services at nexus.civic.com (GitHub, Slack, etc.)
- Node.js 18+ installed
- Complete Civic Auth setup (see Access Token Setup below)
Access Token Setup (Next.js + Civic Auth)
Why Civic Auth? Nexus needs to identify which user is accessing tools and authorize their permissions. Civic Auth provides the secure access token. (Support for additional identity providers coming soon.)- 1. next.config.ts
- 2. API Route
- 3. Middleware
- 4. Get Token
Full Integration Guide
Complete Next.js setup with frontend components, configuration options, and deployment details
AI Prompt for Next.js
Use Claude, ChatGPT, or other AI assistants to automatically set up Civic Auth
Get your Client ID at auth.civic.com
Environment Variables
Create a.env.local
file in your project root:
Getting your API keys:
- Civic Client ID: Visit auth.civic.com, create a new application, and copy the Client ID
- AI Gateway API Key: Visit vercel.com/ai-gateway to get your API key for AI providers
Installation
Install the required packages:Basic Setup
Create Nexus Tools Helper
Complete Example: App Router API route
Using Anthropic/Claude? Replace the model with:
Nexus Authentication
Required Headers
Required Headers
Getting the Access Token
Getting the Access Token
Nexus Endpoint
Nexus Endpoint
Next Steps
1
Try the Starter Template
Clone ai-chatbot for a working example with UI, authentication, and streaming
2
Connect Your Services
Visit nexus.civic.com to connect GitHub, Slack, Notion, and other services
3
Test Tool Calls
Run locally and ask your AI to “list my GitHub repos” or “search Slack messages”
4
Deploy to Production
Deploy to Vercel with one click - all environment variables are pre-configured