Edge functions
Edge functions are small programs that run on Lovable's servers to handle tasks your app can't do in a user's browser, like processing payments or sending emails. Lovable automatically writes, deploys, and scales these functions based on your requests in the project chat.
Anyone building an app with Lovable needs this when their app requires backend tasks that go beyond what happens directly in the user's browser.
Do this, in order
- 1
Describe what you need the function to do in your Lovable project chat.
This is how Lovable understands your requirements and automatically creates, deploys, and maintains the backend code for you.
- 2
If your function needs sensitive information like API keys, make sure those are stored in your project's secrets.
This keeps your sensitive data secure and prevents it from being exposed in the code.
- 3
To check how your functions are performing, go to 'More' then 'Cloud' and select 'Edge functions'.
This allows you to see details like how often a function runs, its success rate, and when it was last updated.
- 4
If a function isn't working as expected, click on it in the 'Edge functions' view and then select 'View logs' to see error messages.
Logs provide crucial information to understand why a function failed, which you can then use to ask Lovable to fix it in the project chat.
Paste this into your project
When a payment is marked 'paid' in Stripe, automatically update the related invoice's status to 'Paid'.
Words decoded
- Edge functions
- These are small pieces of code that run on Lovable's computers, not on your user's device. They handle tasks that need to happen behind the scenes, like talking to other services or processing payments.
- Serverless backend code
- This means you get to use powerful computer programs without having to worry about setting up or managing the actual computers (servers) they run on. Lovable handles all that for you.
- Invocations
- This simply means how many times a particular function has been run or called into action.
- API keys and credentials
- These are like secret passwords or keys that allow your app to securely connect and communicate with other online services.
- Secrets
- A secure place within your Lovable project where you store sensitive information like API keys, so they are not visible in your code or to unauthorized users.
Where people get stuck
- Do not try to manually create or edit edge functions outside of the project chat, as Lovable handles their creation and deployment automatically.
- Remember that edge functions will not run if your Lovable project is paused, causing features that rely on them to stop working.
- Do not embed sensitive information directly into your function's code; always use your project's 'secrets' feature for API keys and credentials.
The short version, steps, decoder and prompt on this page are written automatically from Lovable's own documentation and can lag or misread it. The official page is always the authority.