Skip to main content
The Spidra Next.js integration (spidra-nextjs) brings Spidra’s web intelligence platform natively to Next.js (App Router, Pages Router, and Server Actions). It provides cached client accessors for React Server Components (getSpidraClient()), type-safe wrappers for Server Actions (createSpidraAction()), pre-built Route Handlers for /api/spidra/*, and HMAC-SHA256 webhook handlers.

Installation

Requires Node.js 18+ and Next.js 13+ (fully compatible with Next.js 14 and 15).
Get your API key from app.spidra.io under API Keys. Store it in .env.local. Never commit API keys to version control.

Configuration

Configure credentials in .env.local:
getSpidraClient() automatically reads SPIDRA_API_KEY and optional overrides from your environment.

Integration patterns

1. React Server Components (RSC)

Call Spidra directly inside async Server Components without client-side waterfalls:

2. Server Actions

Use createSpidraAction() to expose type-safe scraping functions callable directly from Client Components:
Call the action from an interactive form:

3. Pre-built Route Handlers

Mount complete Spidra REST API endpoints under /api/spidra/[...action] in one line:
This immediately exposes:
  • POST /api/spidra/scrape
  • GET/POST /api/spidra/search
  • POST /api/spidra/crawl
  • POST /api/spidra/batch
  • POST /api/spidra/map
  • POST /api/spidra/parse
  • GET /api/spidra/account
  • GET /api/spidra/usage

4. HMAC Webhooks

Verify incoming webhook deliveries (crawl.page, crawl.completed, batch.completed) with createSpidraWebhookHandler():
The handler automatically verifies the X-Spidra-Signature header against process.env.SPIDRA_WEBHOOK_SECRET in constant time.

Scraping & browser actions

Run browser automation steps (typing, clicking, scrolling, waiting) before extraction:

Deep site crawling

Recursively crawl domains with path filtering:
Search the web and extract results across multiple sources:

Batch scraping & streaming watchers

Submit up to 50 URLs concurrently and stream items as they finish:

Domain mapping

Document parsing (PDF, Word, Excel)

Ready-made templates & monitors

Error handling

Node.js SDK

Core Node.js / TypeScript SDK documentation and API reference.

Express

Express.js middleware, turnkey router, and error handling.