Enable Lovable Cloud
Turn on Lovable's built-in backend โ Postgres, auth, storage, edge functions โ with zero external accounts.
Create a Postgres table with RLS
Prompt Lovable to create a public table with proper GRANTs and Row Level Security policies in one migration.
User roles the safe way
Never store role on the profile table. Use a dedicated user_roles table + has_role() SECURITY DEFINER function to prevent privilege escalation.
Create a storage bucket + upload
Ask Lovable to create a public/private bucket, RLS-style policies, and a typed upload helper.
When to use an Edge Function vs a server function
Edge Functions are for webhooks, cron, and public HTTP endpoints. For app-internal RPC use TanStack server functions instead.
Add a server secret
Store a third-party API key in Lovable Cloud and read it inside a server function handler.
Run a scheduled job with pg_cron
Schedule a daily cleanup via pg_cron hitting a public API route.
Realtime subscriptions
Subscribe to Postgres change events and re-render a list live.
Migration authoring rules
Every CREATE TABLE in public must be followed by GRANTs before ENABLE RLS โ otherwise the API returns permission errors even with policies in place.
Data backfill safely
Backfill a new column with a batched update to avoid long locks.
Index the hot query paths
The first cause of slow Lovable Cloud pages is a missing index on the query's filter/order columns.
Export your database
Cloud โ Advanced settings โ Export data gives you a downloadable dump when you need it.
Chat completion via Lovable AI Gateway
Call a hosted Gemini/OpenAI chat model from a server function โ no API keys needed.
Stream a chat response
Stream tokens to the browser using a server route + Web Streams.
Generate an image
Use the AI Gateway to generate an image and save it to Cloud storage.
Embeddings + RAG
Store document embeddings in pgvector and retrieve top-k chunks for a chat prompt.
Tool / function calling
Give the model tools it can call and route them to your server functions.
Choose the right model
Match model to task: Flash for cheap/fast, Pro for reasoning, image models for pixels.
AI cost guardrails
Set per-user daily caps and short-circuit before calling the model.
Prompt-injection and safety
Treat all model output and all retrieved content as untrusted input.
Text-to-speech
Generate an MP3 from text and stream it back to the client.
Speech-to-text
Accept an audio blob and return a transcript with word timestamps.
Structured JSON output
Force the model to return typed JSON matching a Zod schema.