Skip to main content
Your Lovable or Bolt app needs a “paste a video link” feature: a user adds a TikTok, YouTube or X link and the video shows up in their library. The download code an app builder writes usually works in the preview and then gets blocked once it runs on a server, and an Edge Function can’t run a downloader anyway. With Importly, the Edge Function sends the link and the file lands in your own Supabase Storage bucket, next to the rest of your app’s data. What you build:
  • start-import, an Edge Function the signed-in user calls with a link. It starts the import and adds a row to a videos table.
  • importly-webhook, a second function that Importly calls when the file is in your bucket. It checks the signature and marks the row ready.
  • A frontend list that shows each user their own videos with signed URLs, so the bucket stays private.
Every step below was tested against a real Supabase project, with a TikTok link imported into a private bucket.

1. Connect your bucket once

Create a private bucket (this guide calls it imports) and an S3 access key in your Supabase project, then save them on the dashboard’s S3 Storage page and click Test connection. The steps and the exact field values are in Supabase Storage setup. Supabase’s S3 access keys can read and write every bucket in the project. Paste them into Importly only, never into your app’s code or a prompt. On the Supabase Free plan, a single file can be at most 50 MB, and a 10-minute 720p video is about 77 MB. A file over your project’s limit doesn’t reach the bucket: the import still completes, and the result has s3StorageError instead of s3Storage. Use a lower videoQuality, audio only (includeVideo: false), or raise the limit on a paid plan. See Supabase’s file limits.

2. Add your Importly keys as secrets

Create your key on the API key page (it is shown once), and copy the Webhook signing secret (it starts with whsec_) from the same page. Store both as Edge Function secrets, in the Supabase dashboard under Edge Functions > Secrets, or with the CLI:
SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY are already available inside every Edge Function.

3. The table and the Storage policy

Run this in the SQL editor. Users can read their own rows, and only the functions write them. The second policy lets a signed-in user create signed URLs for files under users/<their id>/, which is where start-import puts them.

4. Start the import

The frontend calls this function with the user’s session. store: true sends the file to your bucket, storagePath puts it in the user’s folder, and storageFilename gives it a short, predictable name (without it, the file is named after the video’s title, spaces and emoji included).
supabase/functions/start-import/index.ts
A rejected request comes back with Importly’s status, error and code, and no row is written. A wrong IMPORTLY_API_KEY secret, for example, gives a 401 with UNAUTHORIZED. See Error handling. compatibleCodecs gets H.264 video wherever the source has it at that size. TikTok only has H.264 up to 540p, so a 720p TikTok import comes back as HEVC, which some browsers can’t play. Use videoQuality: '480p' if every file has to play everywhere. Each result reports its videoCodec. See Codecs.

5. Mark the row ready from the webhook

Importly sends one signed POST when the job finishes. Importly can’t send a Supabase JWT, so turn off the JWT check for this function. The signature check is what keeps other callers out.
supabase/config.toml
The payload has the file’s place in your bucket under s3Storage.key. Once the signature checks out, the function saves that key on the row:
supabase/functions/importly-webhook/index.ts
A request without a valid signature gets a 400 and changes nothing. The status = 'queued' filter makes a repeated delivery harmless. If the download worked but the copy to your bucket didn’t (a revoked S3 key, say), the payload has s3StorageError instead of s3Storage, and the row records why. See When the copy fails. Deploy both functions:

6. Show each user their videos

The frontend starts an import with supabase.functions.invoke, which sends the user’s session for you, and lists the ready rows with signed URLs. RLS returns only the user’s own rows, and the Storage policy lets them sign only their own files.
src/components/VideoLibrary.tsx
For live updates, turn on Realtime for the videos table (Database > Publications, or alter publication supabase_realtime add table public.videos). Without it, call load() again after a few seconds. The import path is the one Lovable uses; in Bolt or your own setup, import your Supabase client from wherever it lives.

7. Or let the builder write it

Paste this into Lovable or Bolt after step 1, and it builds the same feature:

Video library in Supabase Storage

The builder will ask you to add the two secrets from step 2.

Catch a missed webhook

Each job gets one webhook delivery and no retries, and a function served on localhost never receives it. For rows still queued after a few minutes, read the job with GET /import/status and save result.s3Storage.key the same way. The Supabase Edge Functions recipe has a sweep function you can adapt, run every few minutes with Supabase Cron.
Downloads cost $0.002 per MB, with a $0.01 minimum per import: the 24-second TikTok used to test this guide cost $0.01, and a 10-minute 720p video is about $0.15. Copying the file to your bucket costs nothing extra. Try it free, no card required. See Pricing & credits.
For transcripts instead of files, see Save transcripts to Supabase from an Edge Function. For other app builders and the MCP connector, see Lovable, Bolt & Replit.