Appearance
Hono
Use Firecrawl with Hono to build lightweight web scraping and search APIs that run anywhere.
Prerequisites
- Node.js 18+, Bun, or Deno
- A Firecrawl API key, get one free
Setup
bash
npm install hono @mendable/firecrawl-jsAdd your API key to .env:
bash
FIRECRAWL_API_KEY=fc-YOUR-API-KEYSearch the web
typescript
import { Hono } from "hono";
import Firecrawl from "@mendable/firecrawl-js";
const app = new Hono();
const firecrawl = new Firecrawl({ apiKey: process.env.FIRECRAWL_API_KEY });
app.post("/search", async (c) => {
const { query } = await c.req.json();
const results = await firecrawl.search(query, { limit: 5 });
return c.json(results);
});
export default app;Scrape a page
typescript
app.post("/scrape", async (c) => {
const { url } = await c.req.json();
const result = await firecrawl.scrape(url);
return c.json(result);
});Interact with a page
Use interact to control a live browser session, click buttons, fill forms, and extract dynamic content.
typescript
app.post("/interact", async (c) => {
const { url } = await c.req.json();
const result = await firecrawl.scrape(url, { formats: ['markdown'] });
const scrapeId = result.metadata?.scrapeId;
await firecrawl.interact(scrapeId, { prompt: 'Search for iPhone 16 Pro Max' });
const response = await firecrawl.interact(scrapeId, { prompt: 'Click on the first result and tell me the price' });
await firecrawl.stopInteraction(scrapeId);
return c.json({ output: response.output });
});Deploy anywhere
Hono runs on multiple runtimes. For Cloudflare Workers, pass the API key from the environment binding:
typescript
import { Hono } from "hono";
import Firecrawl from "@mendable/firecrawl-js";
type Bindings = { FIRECRAWL_API_KEY: string };
const app = new Hono<{ Bindings: Bindings }>();
app.post("/search", async (c) => {
const firecrawl = new Firecrawl({ apiKey: c.env.FIRECRAWL_API_KEY });
const { query } = await c.req.json();
const results = await firecrawl.search(query, { limit: 5 });
return c.json(results);
});
export default app;Next steps
Scrape docs
All scrape options including formats, actions, and proxies
Search docs
Search the web and get full page content
Interact docs
Click, fill forms, and extract dynamic content
Node SDK reference
Full SDK reference with crawl, map, batch scrape, and more