Database vs Local Storage: Store user data (profiles, preferences, content) in the database so it syncs across devices. Use MMKV only for local caching. See State Management for details.
Database Schema
- Supabase
- Convex
Security
- Supabase RLS
- Convex Functions
Security is built-in at the database level with Row Level Security (RLS):
- Strict Privacy: Users can only access their own data
- Public Profiles: Basic profile info is publicly readable for social features
- Tokens & Preferences: Strictly private, owner-only access
Managing the Schema
- Supabase
- Convex
Using Migrations (Recommended)
Shipnative uses database migrations to version control schema changes. Always use migrations instead of editingschema.sql directly.Migrations provide version control and prevent “already exists” errors when running the schema multiple times—the industry standard used by Rails, Django, Laravel, and Prisma.Create a New Migration
Apply Migrations
Migration Best Practices
- Always use
IF NOT EXISTS- Makes migrations safe to run multiple times - Drop policies before recreating - Prevents “already exists” errors
- Enable RLS on all user tables - Security best practice
- Add indexes for foreign keys - Performance optimization
See the complete migration guide at
supabase/migrations/README.md in your project.Manual Schema Changes (Not Recommended)
You can also run SQL directly in the Supabase SQL Editor, but this won’t be version controlled:Seed Data
- Supabase
- Convex
Use the SQL Editor to insert test data:Or import from a file:
Reference Implementation: DataDemoScreen
The boilerplate includes a DataDemoScreen that demonstrates proper data fetching patterns for your chosen backend. Use it as a template when building your own data-driven screens.How It Works
The screen uses conditional exports to load the correct implementation:DataDemoScreen.tsx automatically exports the right version based on your EXPO_PUBLIC_BACKEND_PROVIDER setting:
What Each Version Demonstrates
- Supabase Version
- Convex Version
File: Key patterns:
screens/DataDemoScreen.supabase.tsxShows the standard React Query + Supabase SDK pattern:- React Query for caching and state management
- Manual cache invalidation after mutations
- Pull-to-refresh for manual data refresh
- Optimistic updates for better UX
Using the Demo Screen
Navigate to the DataDemoScreen from any authenticated screen:Mock Database
In development without backend credentials, the app uses a mock database:- In-memory storage: Data persists during your session
- Secure storage fallback: Critical data (like auth) persists across restarts
- API compatibility: Same API as the real backend
Next Steps
Authentication
Set up user login and signup
Realtime
Add live updates and presence
Database Prompts
AI prompts for schema design
Mock Services
Develop without a backend

