Skip to main content
Build AI-powered Next.js applications with streaming, server components, and API routes.

Quick Start

1

Simple Usage

2

With Configuration

Streaming Responses

API Route with Streaming

Client with Streaming

Pages Router

Server Components

With Tools

UIMessage Protocol

For compatibility with AI SDK’s useChat:

Environment Variables

Configuration

Best Practices

  1. Use streaming - Better UX for long responses
  2. Handle errors - Show user-friendly error messages
  3. Add loading states - Indicate when AI is thinking
  4. Secure API routes - Add authentication
  5. Cache responses - For repeated queries

Server Adapters

Other server frameworks

Agent

Agent configuration