Edge functions are your server. They run close to your users on Cloudflare's network and are where anything sensitive belongs — API keys, webhook handlers, payment logic, calls to external services.
/When you need one
- 01You have a secret key: Anything that must not reach the browser lives in a function.
- 02You're calling a third party: Stripe, OpenAI, SendGrid — all called from functions, not the client.
- 03You're receiving a webhook: Payment providers and integrations POST to your function's URL.
- 04You need trusted logic: Order totals, quotas, permission checks — never trust the client to calculate them.
You don't write these by hand
Say "when a user signs up, send them a welcome email using Resend" — Lovable creates the function, stores the API key as a secret, and wires the trigger.