crawlfetch

Supabase Edge Functions: download YouTube, TikTok and Instagram videos

Supabase Edge Functions run on Deno, so the CrawlFetch call is plain fetch. Save the result to Supabase Storage.

How it fits together

The function resolves the URL, downloads the file and uploads it to a Storage bucket, returning the stored path.

Supabase Edge Functions example

import { createClient } from "jsr:@supabase/supabase-js@2";
Deno.serve(async (req) => {
const { url } = await req.json();
const r = await fetch("https://api.crawlfetch.com/v1/resolve?" + new URLSearchParams({ url }), {
headers: { Authorization: "Bearer " + Deno.env.get("CRAWLFETCH_KEY") },
});
if (!r.ok) return new Response("resolve failed", { status: r.status });
const video = await r.json();
const file = await fetch(video.downloadUrl);
const supabase = createClient(Deno.env.get("SUPABASE_URL")!, Deno.env.get("SUPABASE_SERVICE_ROLE_KEY")!);
const path = "videos/" + video.id + ".mp4";
await supabase.storage.from("media").upload(path, await file.blob(), { contentType: "video/mp4" });
return Response.json({ path, title: video.title });
});

Notes for Supabase Edge Functions

  • Set the key with supabase secrets set CRAWLFETCH_KEY=….
  • For long videos, prefer a resumable (TUS) upload over a single blob.

FAQ

Can I trigger it from a database insert?

Yes — call the function from a database webhook when a row with a video URL is inserted.

Related

Last updated 2026-10-25

Add video downloads to your product today.

1,000 credits on signup plus 500 every month. That is roughly 180 YouTube clips to start, with no card.

Create free account