arrow_back Back to Blog
supabase edge functionssupabaselovable cloudlovable

Supabase Edge Functions in a Lovable App

·

What are Supabase Edge Functions in a Lovable app? They are the small TypeScript files Lovable writes under supabase/functions/<name>/index.ts whenever your app needs server-side code: a Stripe webhook, an email, a call to an AI API with a key the browser must never see. They run on Deno. Per Supabase’s limits page, checked December 6, 2026, each request gets 256 MB of memory, 2 seconds of CPU time and a wall clock of 150 seconds on Free or 400 seconds on Pro. Pricing is 500,000 invocations a month on Free and 2 million on Pro, then $2 per extra million.

On Lovable Cloud you rarely see them. Lovable’s Cloud docs tuck them away under More, then Database, then Manage, then Edge functions. That’s fine while Lovable runs everything. It stops being fine the day you move the app to your own Supabase project, because the functions come with you as code and almost nothing else does.

The limit that actually bites: 2 seconds of CPU

People read “400 seconds” and assume a function can grind for six minutes. It can wait for six minutes. It can’t think for more than 2.

The CPU limit counts only the time your code is computing, not the time it spends waiting on fetch or the database. So a function that calls OpenAI and waits 40 seconds for an answer is fine. A function that parses a 30 MB CSV in a loop, or resizes a photo in JavaScript, gets killed with a resource error long before the wall clock matters.

One Edge Function request on a timeline: a 2 s CPU budget inside a 150 s or 400 s wall clock, with the 150 s idle cutoff

Image work is the usual victim. The limits page says multithreaded Node libraries such as sharp and libvips aren’t supported at all, so the “resize the avatar on upload” function Lovable sometimes writes either fails or eats the CPU budget doing it in pure JS. Use Supabase Storage’s image transformations, or push the job to a proper worker.

Two more numbers from the same page that come up in real apps:

  • Idle timeout, 150 seconds. If the function sends nothing back for 150 seconds, the caller gets a 504. Long AI calls should stream.
  • Ports 25 and 587 are blocked. An SMTP library will hang. Send email through an HTTP API instead (Resend, Postmark, SES), which is what most Lovable apps should do anyway.

What it costs

Almost nothing, for most apps. Pro includes 2 million invocations a month, and the Lovable apps we move usually use somewhere between 50,000 and 300,000. You would have to be calling a function on every page view of a busy site to see the $2 line.

The real cost of functions shows up elsewhere: an AI function with no rate limit that someone scripts against, or a webhook that retries forever because it keeps failing. The invocation bill stays tiny while the OpenAI bill does not.

PlanIncluded invocationsOver the quota (checked Dec 6, 2026)
Free500,000no overage listed; upgrade to Pro
Pro ($25)2 million$2 per million
Team ($599)2 million$2 per million

If you’re still deciding whether the move is worth it, the Supabase pricing breakdown covers the rest of the bill, and our Lovable cost check reads your repo and estimates it for you.

What breaks when the functions move

The code is in your GitHub repo, so it moves for free. You deploy it to the new project with supabase functions deploy. Three things don’t move, and they cause most of the “it worked on Lovable” tickets we get.

Secrets

Your Stripe key, your OpenAI key, your Resend key: they lived in Lovable’s Secrets panel and they stay there. Even Lovable’s own remix only copies secret names, not values. You set them again on the new project with supabase secrets set --env-file .env (secrets docs). No redeploy is needed; functions read new secrets straight away.

Two rules from those docs trip people up. Your own secret names can’t start with SUPABASE_, because that prefix is reserved. And the built-in keys have changed shape: new projects expose SUPABASE_PUBLISHABLE_KEYS and SUPABASE_SECRET_KEYS as JSON objects you parse and pick from, while SUPABASE_SERVICE_ROLE_KEY is now marked legacy. A function that reads Deno.env.get("SUPABASE_SERVICE_ROLE_KEY") may still work on your project. Don’t assume it will on the next one.

JWT checks on webhooks

By default every Edge Function demands a valid user JWT in the Authorization header (function configuration). Stripe doesn’t send one. Neither does Twilio, GitHub, or a cron service.

We moved a booking app in October where every Stripe event came back 401 after the switch. Payments went through, bookings never confirmed, and Stripe kept retrying for its full three days before anyone noticed the dashboard full of red. The fix is two lines in supabase/config.toml:

[functions.stripe-webhook]
verify_jwt = false

Then check Stripe’s signature inside the function yourself. Turning off the JWT check without that means anyone on the internet can call your webhook with a fake “payment succeeded” body.

URLs baked into the frontend

The functions now live at https://<new-project>.supabase.co/functions/v1/<name>. If the app calls them through supabase.functions.invoke, it follows the client config and you’re fine. If Lovable hard-coded the old Cloud URL anywhere (it happens in webhook settings, OAuth redirect lists and the odd fetch), those calls keep hitting the old project. Search the repo for the old project ref before you switch DNS, and update the webhook URL in Stripe’s dashboard the same hour.

Our checklist for every function

Before a Lovable app goes live on its own Supabase, we open every folder under supabase/functions and answer four questions. Does it need a user JWT, or is it called by another service? Which secrets does it read, and are they set on the new project? Does it do heavy work that could pass 2 seconds of CPU? Does it send email over SMTP? Most apps have 4 to 12 functions, and this takes an hour.

That hour is part of every Lovable Cloud to Supabase migration we do, from $150, usually finished in 1 to 2 days. If you’d rather do it yourself, the migration checklist has the full order of steps.