An email lands saying your project has gone over its storage or egress quota. Or the Lovable usage chart shows run credits climbing even though only a handful of customers use the app. Upgrading looks like the fastest way out, but if an image gallery downloads full-size photos on every visit, a bigger plan only buys time until the next limit.
This guide first finds which number you’ve hit and what drives it, then covers the fixes that lower usage without changing your plan: smaller uploads, smaller images, caching, private files served the right way, and cleaning up files nobody points to. It quotes no plan numbers, because those change; the linked docs have the current figures.
First: which backend is your app on?
The same app can be billed in two very different ways, and the screens you need are in different places.
| Lovable Cloud (built-in backend) | A Supabase project you own, connected to Lovable | |
|---|---|---|
| Who bills you | Lovable, in credits | Supabase, on your Supabase plan |
| Where usage shows | More → Usage in the Lovable project | The organization Usage page in the Supabase dashboard |
| What “over the limit” means | Cloud usage has spent the month’s Cloud grant plus all general credits | Storage size or egress is above your plan’s quota |
| Where files live | More → Storage | Storage in the Supabase dashboard |
Lovable’s Supabase integration page sets this out: the built-in backend draws on credits in your Lovable workspace, while Supabase bills a connected project under your own subscription, and its limits on database size, upload size and bandwidth follow that plan. Our Lovable and Supabase tool pages collect the related guides. If you aren’t sure which backend you have, open More in the Lovable project. A Supabase entry showing your project’s name, with links to the Supabase dashboard, means you connected your own project.
Storage size or egress: which one did you hit?
These are two separate meters, and they need different fixes.
- Storage size is how much data sits in your buckets. Supabase measures it in gigabyte-hours, so the figure used for quota and billing is the average over the billing period, not what the bucket holds right now (Supabase: Manage Storage size usage). Deleting files late in a cycle only pulls that average down gradually.
- Egress is data sent out to clients. Supabase counts it across the database API, Auth, Storage, Edge Functions, Realtime, the shared pooler and log drains, against one quota for the whole organization. Requests answered from the CDN cache count as cached egress, which has its own quota and a lower price (Supabase: Manage Egress usage).
On a Supabase project, open the organization’s Usage page and pick the project from the dropdown. Hover over a day in the Total Egress chart to see it split by service, cached egress included, so you can tell whether Storage or the database API is the heavy one. Storage size has its own section on the same page.
On Lovable Cloud, open More → Usage and expand Run. Workspace owners can always open this view, and workspace admins can on paid plans. Lovable lists the categories from highest to lowest. Storage is the files your app keeps, and Network is data your app sends and receives, including downloads, uploads, images and media (Lovable: Project usage and costs). An image your app serves counts toward Storage while it is stored and toward Network each time it is sent to a visitor (Lovable: Credits and usage), so a large Network figure is the closest Lovable Cloud equivalent of an egress problem.
What happens over the limit
Your own Supabase project. Supabase’s usage pages split this by plan. On a paid plan with the Spend Cap off, or on Team and above, overages are billed. On the Free plan, or with the Spend Cap on, Supabase emails your billing address and starts a grace period. If usage keeps going over, the Fair Use Policy allows restrictions such as a read-only database, paused projects, or a 402 status on every API request, and says restrictions generally apply to every project in the organization. The same page says you don’t get a second grace period: once one has ended, going over again leads straight to restrictions.
That 402 is an error you can read. Supabase says the response carries a description with one or more codes: an exceed_... code such as exceed_egress_quota, or overdue_payment (Supabase: HTTP status codes). For storage, Supabase’s troubleshooting article names the code exceed_storage_size_quota (Supabase: Unexpectedly high storage usage). Your data stays reachable in the Supabase dashboard while restricted. Usage restrictions lift when the quota refills at the start of the next billing cycle, or straight away if you upgrade from Free or turn off the Spend Cap. Egress already served can’t be taken back, and pausing or deleting a project doesn’t remove usage already counted in the current cycle, so the fixes below lower future usage only.
Lovable Cloud. Lovable’s docs don’t describe a gigabyte quota for files. Cloud usage, storage and network included, comes out of the monthly Cloud grant first and then your general credits. When both are gone, Lovable pauses the app’s backend services, such as the database, storage and sign-in. The published pages stay up, but anything that needs the backend stops answering until you add credits and select Wake up under More → Database (Lovable: Out of credits). A usage limit you set yourself can pause the backend the same way. Daily build credits don’t pay for Cloud, so they won’t keep it running. And pausing doesn’t stop storage charges: Lovable’s Storage docs say storage usage continues while a project is paused, because the files are still there.
Find the largest and most-downloaded files
Supabase keeps a row for every stored file in the storage.objects table, with the size in its metadata column. Run these in the SQL Editor of your Supabase project. They only read.
Total per bucket:
select
bucket_id,
count(*) as files,
sum((metadata->>'size')::bigint) as bytes,
pg_size_pretty(sum((metadata->>'size')::bigint)) as total_size
from storage.objects
group by 1
order by bytes desc nulls last;
The 50 largest files:
select
bucket_id,
name,
(metadata->>'size')::bigint as bytes,
pg_size_pretty((metadata->>'size')::bigint) as size,
metadata->>'mimetype' as type,
created_at
from storage.objects
order by bytes desc nulls last
limit 50;
If a bucket has object versioning turned on, older versions count toward storage size and appear in these results too. Supabase’s storage size page says to add archived_at is null to the where clause to count only current versions.
On Lovable Cloud, open More → Storage and then a bucket: each file is listed with its size and type. For a ranked list, ask Lovable in chat to run the second query above against your backend and show the results without changing anything. If it can’t query that table, use the file list and sizes on that page. Lovable’s usage page also says you can ask it in chat what drives the project’s run credit usage, and workspace admins and owners see an Optimize button below the usage chart once the project has used more than 5 run credits in the last 7 days.
Large files explain storage size. For egress, you want the files that are downloaded again and again. Supabase’s egress page points to the Query performance view for the most frequent database queries and to API Gateway logs for the most requested paths. Those logs don’t include response sizes yet, so pair the path counts with the file sizes from the query above. A 4 MB banner fetched 1,000 times sends about 4 GB; a 200 MB video opened once sends 200 MB.
Shrink what users upload
A bucket can reject files over a size you choose and files outside the types you allow. In Supabase that is set per bucket with fileSizeLimit and allowedMimeTypes (Supabase: Creating buckets), below a global limit in Storage → Settings that applies to every bucket (Supabase: Storage upload limits). An upload over the limit fails with EntityTooLarge and status 413 (Supabase: Storage error codes), so make sure your upload form shows that error to the user instead of failing silently.
On Lovable Cloud, the project-wide limit is under More → Storage → Settings → Upload size limit. Per-bucket limits and allowed file types can’t be edited on the Storage page; ask Lovable in chat to set them and to read the current values back to you.
For photos, resize before upload. A profile picture shown 96 pixels wide doesn’t need a full-resolution camera original. In the browser, draw the image onto a canvas at the largest size you display and export it with canvas.toBlob() before calling upload(). Check the type of the blob you get back: if a browser can’t encode the format you asked for, it returns a PNG instead (MDN: toBlob()), and Safari can’t encode WebP from a canvas (Can I use: toBlob WebP). Ask for 'image/webp' and fall back to 'image/jpeg' when the blob’s type isn’t image/webp. Keep the original only if your app has a real use for it.
Serve smaller images
On your own Supabase project, Storage can resize and compress images when they are requested. Pass a transform option to getPublicUrl or createSignedUrl, for example a width of 400 and a quality of 70 for a card thumbnail. Supabase then returns WebP to browsers that accept it, unless you ask for the original format (Supabase: Storage image transformations). The feature is not on every plan, is switched on with Enable Image Transformations in Storage → Settings, and is billed by the number of distinct source images transformed in a billing period (Supabase: Manage Storage Image Transformations usage), so check both pages against your plan first.
Lovable’s storage docs don’t describe an image transformation setting for Lovable Cloud, so there, resize at upload time as above. Either way, match the image to where it is shown: a list of 30 products needs 30 thumbnails, not 30 originals.
Cache files instead of re-downloading them
Supabase’s storage optimization guide lists a long browser cache as one of its egress fixes: a file the browser already holds isn’t sent again. You set it per file with the cacheControl upload option, in seconds. The Smart CDN page gives the default browser lifetime as typically one hour.
A long cache is safe when a file never changes at its path. Build the path from something unique, such as avatars/${userId}/${crypto.randomUUID()} plus the file’s extension, save that path on the row, and upload with a year-long cacheControl of '31536000'. When the user replaces the picture, upload to a new path and delete the old file. The Smart CDN page explains why: the CDN copy is invalidated when a file changes, but browsers that already hold the file may keep showing the old one, so files that change often belong at new paths.
Public and private buckets cache differently. In a public bucket, the next visitor in the same region can be served straight from the CDN. In a private bucket, Storage checks each user’s access, so the next user’s request is another cache miss (Supabase: Storage CDN). Files that are truly public, such as product photos and blog images, belong in a public bucket for that reason. On Lovable Cloud, public buckets are blocked by a workspace setting by default, and a workspace owner or admin can turn that block off (Lovable: Storage).
Then look at the code that displays files. These patterns turn one visit into repeated downloads:
- A
useEffectthat callsdownload()orcreateSignedUrl()every time a component mounts, inside a list that re-renders. - A fresh signed URL on every render. Each signed URL carries its own token, and the Smart CDN treats every token as a separate cache entry, so a new URL each time is never served from cache.
- Polling a file, or a list of files, on a timer.
- An
<img>pointing at a full-size original that CSS then shrinks.
Private files: private buckets and signed URLs
Invoices, contracts, ID photos and anything else that belongs to one customer goes in a private bucket. New Supabase buckets start out private, and a private file can only be fetched with the user’s own session, subject to your policies on storage.objects, or through a signed URL that expires (Supabase: Storage buckets). For the policies that limit each user to their own folder, see the folder-based storage policies in our RLS guide rather than writing new ones from scratch.
For a client portal, the shape is:
- Upload to a path that starts with the owner’s user ID, for example
${user.id}/${documentId}.pdf. - Keep the path, not a URL, in your table.
- When the customer opens their documents page, call
createSignedUrl(path, expiresIn)once per file, withexpiresInin seconds, and reuse that URL while the page is open. - Refresh the URL only when it is close to expiring.
One detail from the Smart CDN page matters here: letting a signed URL expire doesn’t remove a copy the CDN has already cached for that exact URL, and the cached response can keep being served until the cache duration runs out. To cut off access to a file, delete it.
Clean up files nobody points to
Deleting a row in your table doesn’t delete the file its path pointed to. The file stays in Storage and keeps counting toward storage size until something removes it. To find files with no matching row, adapt this to your own table and column names. Here, public.documents.file_path holds the path of each file in the documents bucket:
select
o.name,
(o.metadata->>'size')::bigint as bytes,
pg_size_pretty((o.metadata->>'size')::bigint) as size,
o.created_at
from storage.objects o
left join public.documents d
on d.file_path = o.name
where o.bucket_id = 'documents'
and d.id is null
order by bytes desc nulls last;
Delete what it finds through the Storage API, for example supabase.storage.from('documents').remove([...paths]), which takes up to 1,000 paths per call. Don’t run delete from storage.objects in SQL. Supabase warns that this removes the database row but leaves the file itself in the bucket, orphaned (Supabase: Delete objects), and its troubleshooting article names those orphans as a cause of exceed_storage_size_quota after files seem deleted. Because their rows are gone, files orphaned that way won’t show up in the queries above. In a bucket with versioning turned on, a delete adds a delete marker and keeps earlier versions, so storage size doesn’t drop until those versions are removed too; the same page covers how.
To stop new orphans, change the delete action in your app so it removes the file through the Storage API along with the row, ideally in one server-side function, and keep the row if the file delete fails so you can retry it.
Prompt to give Lovable
Paste this into your Lovable chat, and review the plan before you approve it:
Our file storage and download usage is too high. Before changing anything, report back:
1. Every storage bucket, whether it is public or private, its file size limit and allowed file types.
2. Every place in the code that uploads, downloads, lists or creates a URL for a stored file, and whether it runs on every render or inside a list.
3. The 50 largest files, and any files with no matching database row.
Then propose, without applying yet:
- Resize images in the browser before upload to the largest size we display, as WebP, falling back to JPEG when the browser returns a different type.
- Unique file paths per upload, with cacheControl set to one year.
- Create each signed URL once per page view and reuse it until it is close to expiring.
- When a record is deleted, delete its file through the Storage API, never with SQL.
- Per-bucket file size limits and allowed MIME types that match what each bucket is for.
Keep customer documents in private buckets.
Prevent the next surprise
- Put a monthly reminder in your calendar to check Usage (Supabase organization page, or More → Usage in Lovable) and compare it with the month before.
- On Lovable, add credit limits and low-balance alerts for the workspace, a project or a member (Lovable: Usage limits and alerts). Remember that a limit which blocks Cloud usage can pause the backend.
- On Supabase, decide on purpose whether the Spend Cap is on. With it on, usage past the quota is disallowed instead of billed, and restrictions follow if you keep going over; with it off, overages are billed (Supabase: Cost control).
- Only signed-in users should be able to upload, and only into their own folder. An open upload policy lets anyone fill your bucket. The security checklist has a quick test for bucket access.
- If you’re planning a move off Lovable Cloud onto a Supabase project you own, files are copied separately from the database; moving off Lovable Cloud covers that step. If your Supabase project stopped answering and there’s no quota email, check whether it was paused for inactivity instead.
FAQ
Why is egress so high with only a few users?
Egress depends on the bytes each visit downloads as well as the number of visitors. A few users can produce a lot of it when every page loads full-size originals, when the code creates a new signed URL or calls download() on each render, when something polls on a timer, or when a public file is embedded on another site. Check the per-service breakdown on the Usage page first, then the largest files.
What expiry should a signed URL have?
Long enough for the page that uses it, and no longer: a few minutes for a one-off download, up to the length of a session for a gallery the user keeps open. Create it once and reuse it during that time so it can be cached. Lovable’s Copy URL button in the Storage view makes links that expire after one hour. Expiry isn’t a kill switch, since a cached response can outlive the token, so delete a file when access must end.
Is there a separate storage limit on Lovable Cloud?
Lovable’s docs don’t describe a gigabyte quota like a Supabase plan’s. Files and network traffic use Cloud credits (Lovable: Credits and usage), and the backend pauses once the month’s Cloud grant and the rest of your credits are used up (Lovable: Out of credits). There is a separate per-file upload size limit, which you can change under More → Storage → Settings. If your Lovable app is connected to your own Supabase project, Supabase’s quotas for your plan apply instead.
Comments