Skip to main content

Next.js

Use Firecrawl with Next.js to scrape, search, and interact with web data in your React application.
1 min read

Prerequisites#

  • Next.js 14+ project (App Router)
  • A Firecrawl API key — get one free

Install the SDK#

Set your API key#

Add your API key to .env.local:

Search the web#

The SDK should only run server-side since it requires your API key.

Route Handler#

Create app/api/search/route.ts:

Server Action#

Create app/actions.ts for use from Client Components:

Scrape a page#

Route Handler#

Create app/api/scrape/route.ts:

Server Component#

Fetch data directly in a Server Component at app/page.tsx:

Interact with a page#

Use interact to control a live browser session — click buttons, fill forms, and extract dynamic content.

Route Handler#

Create app/api/interact/route.ts:

Next steps#