I kept hitting the same wall adding a "paste a video link" feature to Supabase apps: it works in the Lovable or Bolt preview, then the deployed version just stops returning files. If you have shipped a Lovable or Bolt app on Supabase and tried to add "user pastes a TikTok, YouTube or X link and the video shows up in their library," you have probably seen this too.
Two things are going on:
- The download code works on your machine and in the preview, then datacenter IPs get blocked once it runs from a server.
- You can't run a downloader inside a Supabase Edge Function anyway. It runs out of memory or times out on anything but a tiny clip - the 546 and timeout errors. I wrote those specific errors up in Edge Function video limits.
The setup that actually holds up is to not download anything in your own function. You hand the link to an API, and the file lands straight in your own Supabase Storage bucket, with a webhook when it's ready. I built Importly for exactly this - you send it a URL, it puts the file in your bucket - so that's what the code below uses. It's free to try, no card.
Here's the shape of it. The full tested version - table, RLS policies, signature check, frontend - is in the guide; this is the part that matters.
1. Connect your bucket once
Create a private bucket and a Supabase S3 access key, paste the key into Importly's dashboard once, and hit Test connection. Your app code never touches it.
2. A start-import Edge Function
The signed-in user calls it with a link. It sends the link on and records a row:
const res = await fetch('https://api.importly.io/import', { method: 'POST', headers: { Authorization: `Bearer ${Deno.env.get('IMPORTLY_API_KEY')}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ url, store: true, storagePath: `users/${user.id}`, storageFilename: crypto.randomUUID(), videoQuality: '720p', compatibleCodecs: true, // H.264 where the source has it, so it plays everywhere maxCostDollars: 0.5, // links come from users, so cap each import webhookUrl: `${Deno.env.get('SUPABASE_URL')}/functions/v1/importly-webhook`, }), }) store: true with storagePath is the whole trick: the file goes to users/<id>/ in your bucket, not back through your function. Read the key from a secret, never from client code.
3. A webhook function marks the row ready
Importly sends one POST when the file is in the bucket. You verify the signature with your webhook secret and save data.s3Storage.key on the row. Turn verify_jwt off for that function - the signature is what keeps other callers out - and deploy it with --no-verify-jwt. The full signature-check code is in the guide.
4. The frontend signs the user's own files
List the ready rows and call createSignedUrls, with a Storage policy that lets a user sign only files under users/<their id>/. The bucket stays private.
A few things that cost me time
- Supabase Free caps a file at 50 MB, and a 10-minute 720p video is about 77 MB. Over the limit, the import still finishes but the result has
s3StorageErrorinstead ofs3Storage- have your webhook record that, not leave the row silently queued. LowervideoQuality, go audio only, or raise the cap on a paid plan. - Codecs.
compatibleCodecs: truegets H.264 where the source has it. TikTok only has H.264 up to 540p, so a 720p TikTok comes back as HEVC and some browsers won't play it. Use480pif every file has to play everywhere. - Missed webhook. A function on
localhostnever receives the call, and retries back off to hours apart, so pollGET /import/statusfor rows still queued after a few minutes.
If you'd rather have the agent write it, there's a paste-in prompt at the bottom of the guide that builds the same feature.
Cost, so there are no surprises: downloads are $0.002/MB with a $0.01 minimum, so the 24-second TikTok I tested with cost a cent and a 10-minute 720p video is about $0.15. Copying the file into your bucket is free.
Full tested guide: Save videos from a link to Supabase Storage.