Appearance
Supabase Edge Functions
Use Firecrawl with Supabase Edge Functions to search, scrape, and interact with web data at the edge.
Prerequisites
- Supabase project with CLI (
supabase init) - A Firecrawl API key, get one free
Setup
bash
supabase functions new firecrawl-search
supabase functions new firecrawl-scrape
supabase functions new firecrawl-interactSet the secret:
bash
supabase secrets set FIRECRAWL_API_KEY=fc-YOUR-API-KEYSearch the web
Edit supabase/functions/firecrawl-search/index.ts:
typescript
import Firecrawl from "npm:@mendable/firecrawl-js";
const firecrawl = new Firecrawl({
apiKey: Deno.env.get("FIRECRAWL_API_KEY"),
});
Deno.serve(async (req) => {
const { query } = await req.json();
const results = await firecrawl.search(query, { limit: 5 });
return new Response(JSON.stringify(results), {
headers: { "Content-Type": "application/json" },
});
});Scrape a page
Edit supabase/functions/firecrawl-scrape/index.ts:
typescript
import Firecrawl from "npm:@mendable/firecrawl-js";
const firecrawl = new Firecrawl({
apiKey: Deno.env.get("FIRECRAWL_API_KEY"),
});
Deno.serve(async (req) => {
const { url } = await req.json();
const result = await firecrawl.scrape(url);
return new Response(JSON.stringify(result), {
headers: { "Content-Type": "application/json" },
});
});Interact with a page
Edit supabase/functions/firecrawl-interact/index.ts:
typescript
import Firecrawl from "npm:@mendable/firecrawl-js";
const firecrawl = new Firecrawl({
apiKey: Deno.env.get("FIRECRAWL_API_KEY"),
});
Deno.serve(async (_req) => {
const result = await firecrawl.scrape("https://www.amazon.com", {
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",
});
console.log(response.output);
await firecrawl.stopInteraction(scrapeId);
return new Response(JSON.stringify({ output: response.output }), {
headers: { "Content-Type": "application/json" },
});
});Deploy
bash
supabase functions deploy firecrawl-search
supabase functions deploy firecrawl-scrape
supabase functions deploy firecrawl-interactTest it
bash
curl -X POST https://<project-ref>.supabase.co/functions/v1/firecrawl-search \
-H "Authorization: Bearer <ANON_KEY>" \
-H "Content-Type: application/json" \
-d '{"query": "firecrawl web scraping"}'Next steps
Search docs
Search the web and get full page content
Scrape docs
All scrape options including formats, actions, and proxies
Interact docs
Click, fill forms, and extract dynamic content
Node SDK reference
Full SDK reference with crawl, map, batch scrape, and more