Skip to content
Back to Templates

NextJS + Parallel Starter

A Next.js template demonstrating how to integrate Parallel's web research APIs with Vercel. This template provides a complete demo applicati

Contentful thumbnail for NextJS + Parallel Starter

Parallel + Vercel Template

A Next.js template demonstrating how to integrate Parallel's web research APIs with Vercel. This template provides a complete demo application showcasing the Search, Extract, and Tasks APIs with real-time SSE streaming.

View the demo at: https://parallel-vercel-template-cookbook.vercel.app/

Features

FeatureDescription
Search APINatural language web search with mode selection (one-shot vs agentic)
Extract APIContent extraction from URLs with objective-focused filtering
Tasks APIDeep research tasks with real-time SSE event streaming
Session PersistenceSearch/Extract results persist in sessionStorage, Tasks persist in localStorage
Status RecoveryAutomatically checks and updates pending task statuses on page reload

Architecture

┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ React UI │────▶│ Next.js API │────▶│ Parallel API │
│ Components │ │ Routes │ │ (parallel-web) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │
│ sessionStorage │ SDK calls
│ localStorage │
▼ ▼
┌─────────────────┐ ┌─────────────────┐
│ SearchDemo │ │ /api/search │ → client.beta.search()
│ ExtractDemo │ │ /api/extract │ → client.beta.extract()
│ TasksDemo │ │ /api/tasks │ → client.taskRun.create()
└─────────────────┘ │ /api/tasks/[id]/status │ → client.taskRun.retrieve()
│ /api/tasks/[id]/events │ → client.beta.taskRun.events()
└─────────────────┘

How It Works

  1. Search: User enters a search objective and optional queries → API calls client.beta.search() → Returns ranked results with excerpts
  2. Extract: User enters URLs and optional objective → API calls client.beta.extract() → Returns extracted content
  3. Tasks: User enters a research task → API calls client.taskRun.create() → SSE stream delivers real-time progress → Final output displayed on completion

Quick Start

Prerequisites

1. Clone and Install

cd typescript-recipes/parallel-vercel-template
npm install

2. Configure Environment

cp .env.example .env.local

Edit .env.local with your Parallel API key:

PARALLEL_API_KEY=your-api-key-here

3. Run the Development Server

npm run dev

Open http://localhost:3000 to see the demo.

Project Structure

parallel-vercel-template/
├── app/
│ ├── api/
│ │ ├── search/route.ts # Search API endpoint
│ │ ├── extract/route.ts # Extract API endpoint
│ │ └── tasks/
│ │ ├── route.ts # Create task endpoint
│ │ └── [runId]/
│ │ ├── status/route.ts # Task status polling
│ │ └── events/route.ts # SSE event streaming
│ ├── components/
│ │ ├── SearchDemo.tsx # Search UI with mode toggle
│ │ ├── ExtractDemo.tsx # Extract UI
│ │ └── TasksDemo.tsx # Tasks UI with SSE streaming
│ ├── page.tsx # Main page with tabs
│ ├── layout.tsx # App layout
│ └── globals.css # Tailwind styles
├── .env.example # Environment template
├── package.json
└── README.md

Deploying to Vercel

  1. Push to your GitHub repository
  2. Import the project in Vercel
  3. Add PARALLEL_API_KEY to Environment Variables
  4. Deploy

Using Vercel Integration

The easiest way to get an API key is through the Parallel Vercel Integration:

  1. Install the integration on your Vercel project
  2. The PARALLEL_API_KEY environment variable is automatically added
  3. Access the Parallel playground by clicking "Open in Parallel Web Systems"

Exploring More APIs

Want to try the Monitor or FindAll APIs?

Go to your Vercel Integration page, select a project, and click "Open in Parallel Web Systems" to access the full playground.

Resources

License

MIT