Skip to main content
Learn how to integrate Icepick agents into your Next.js application for seamless AI-powered functionality.

Installation

First, install the Icepick SDK:

Basic Setup

Create your agent in a separate file (e.g., lib/agents/my-agent.ts):

API Routes Integration

Create an API route to handle agent execution (pages/api/agent.ts or app/api/agent/route.ts):

Pages Router

App Router

Client-Side Usage

Use the agent from your React components:

Server Actions (App Router)

For App Router, you can also use Server Actions:
Then use it in your component:

Environment Configuration

Add your Hatchet configuration to .env.local:
Initialize Hatchet in your application:

Deployment

When deploying to Vercel or other platforms, ensure your environment variables are configured and your agent workflows are properly registered. For serverless deployments, consider using runNoWait() for long-running agents and add a get endpoint to subscribe to the result to avoid timeout issues.