DirFast uses Supabase for PostgreSQL data, file storage, and user authentication. The repository includes the initial schema in supabase/migrations/ and local settings in supabase/config.toml.
Local project
The Quickstart starts Supabase locally and runs the migration. The migration creates the content tables, the public images storage bucket, row-level security policies, and the trigger that creates a profile when a user signs up.
Use these commands when you need to rebuild the local database.
supabase start
supabase db reset
supabase statusThe local Auth callback is configured for /auth/callback on ports 3000 and 3001 in supabase/config.toml. If you use another local port, add that callback URL to the Supabase Auth settings.
Hosted project
Create a project in the Supabase dashboard, then link the repository to it.
supabase login
supabase link --project-ref <project-ref>
supabase db pushThe production database receives the same migrations that are tested locally. Do not use supabase db reset for a hosted project.
In Supabase Authentication, set the Site URL to your production domain and add this redirect URL.
https://<your-domain>/auth/callbackAdd the Vercel preview callback too if you need to test authentication from preview deployments.
Create the first admin
- Run the app and register an account.
- Open Authentication → Users in the Supabase dashboard and copy the user's UUID.
- Open Table Editor → profiles and change that row's
rolefromUSERtoADMIN. - Sign out and sign back in to refresh the session.
- Open
/adminand confirm the Refine admin interface loads.
The role is stored in public.profiles.role. Admin server helpers check this value before allowing CMS and moderation operations. Keep the service role key on the server and never expose it as a NEXT_PUBLIC_* variable.
Storage
The migration creates a public bucket named images. The app uses it for listing, blog, and uploaded content images. Confirm the bucket exists under Storage after applying the migration. If you create a new Supabase project manually, run the migrations before testing uploads so the bucket and policies are present.
Database types
Regenerate the local TypeScript definitions after schema changes.
yarn typegen:supabaseReview the generated file at src/lib/supabase/database.types.ts before committing a schema change.
