Supabase Database
Supabase provides a full PostgreSQL database for storing your app’s data. Create tables, write queries, and let your data scale.Prerequisites
- Supabase connected
- Basic understanding of your data needs
Creating Tables
In Supabase Dashboard
- Go to Table Editor in sidebar
- Click Create a new table
- Name your table (e.g.,
tasks) - Add columns
Via Nativeline
You can also ask Nativeline:Common Column Types
Example: Tasks Table
Row Level Security (RLS)
Enable RLS
- Table Editor → Select table
- Toggle “RLS” to enabled
- Add policies
Common Policies
Users see only their data:CRUD Operations
Create (Insert)
Read (Select)
Update
Delete
Querying Data
Basic Queries
Filtering Options
Relationships
One-to-Many
Tasks belong to a category:Querying with Relationships
Handling Errors
Common Database Errors
Error Handling in App
Performance Tips
Add indexes for frequent queries
Add indexes for frequent queries
If you often query by a column (like
user_id), add an index:Select only needed columns
Select only needed columns
Instead of
select("*"), specify columns:Use pagination for large datasets
Use pagination for large datasets
Cache locally for speed
Cache locally for speed
Store frequently-accessed data locally and sync with Supabase.
Testing Database Operations
In Supabase Dashboard
- Table Editor → Select table
- View, add, edit, delete rows manually
- Great for testing and debugging
Via SQL Editor
- SQL Editor in Supabase sidebar
- Write and run queries directly
- Test policies and queries
Next Steps
Storage
Upload files and images
Realtime
Live data updates