Handle files and live data.

Storage and realtime are separate capabilities from ordinary database queries. Prove the base table or bucket access first, then add the subscription or file policy with the smallest scope possible.

Lovable + Supabase · 8 min read · Updated 2026-06-06

Storage workflow

Work through these steps in order. Each one builds on the last, so resist skipping ahead even if a step feels familiar.

  1. Choose a bucket visibility model before uploading anything.
  2. Create upload and read policies for the intended user role.
  3. Use stable paths that include an ownership boundary where appropriate.
  4. Store the object path in the database, not a temporary upload response alone.
  5. Test access after refresh and from a second user account.

Realtime workflow

Subscribe to the exact table and event set the screen needs. Confirm the table is enabled for realtime, the filter uses the correct column and the authenticated session is present before opening the subscription.

  • Keep subscription cleanup tied to the component lifecycle.
  • Avoid subscribing to an entire large table when a filtered stream is enough.
  • Handle reconnects and show the last known state honestly.
  • Do not use realtime to compensate for missing initial data loading.
A public bucket is not automatically safe for private files. Decide whether the asset is public, signed or user-owned before choosing policies.

Storage handover checklist

The list below breaks this down into the parts that matter most. Read through each one and note anything that applies to your own setup.

  • Bucket visibility (public, signed URL or authenticated only) is documented and matches the policies.
  • File size and type limits are enforced before upload, not only assumed.
  • Orphaned files are handled: deleting a database row also removes or schedules removal of the associated object.
  • Uploaded paths cannot be guessed to access another user's file.
  • Thumbnails or derived files are regenerated correctly after the source file changes.

Realtime diagnostic sequence

Work through these steps in order. Each one builds on the last, so resist skipping ahead even if a step feels familiar.

  1. Confirm a plain select query returns the expected rows for the user.
  2. Confirm the table has realtime enabled at the database level.
  3. Check the subscription filter matches the column and value used in the actual data.
  4. Watch the browser console for subscription connect, disconnect and error events.
  5. Confirm the component unsubscribes on unmount to avoid duplicate or stale event handlers.

Questions

Only if every file in it is meant to be publicly accessible to anyone with the URL. For private or user-owned files, use authenticated access or signed URLs with a policy that checks ownership, not just bucket-level visibility.

The most common causes are realtime not being enabled for that table, a filter that does not match the inserted row, or the subscription being opened before the authenticated session is ready. Check each in that order.

No. A one-time load should use a normal query on mount. Reserve realtime for data that genuinely changes while the user is looking at the screen, since subscriptions add connection and cleanup overhead that plain queries do not need.

Want your app built properly?

We take Lovable prototypes to production: secure data, real auth and a clean deploy.