Prerequisites
- A Supabase account (sign up at supabase.com)
- Node.js 18 or higher installed locally
- Access to your deployment platform (Netlify, Vercel, etc.)
Create a Supabase project
Create new project
- Log in to your Supabase Dashboard
- Click “New Project”
- Enter your project details:
- Name: DoctorSoft Production (or your preferred name)
- Database Password: Generate a strong password and save it securely
- Region: Choose the region closest to your users
- Pricing Plan: Select based on your needs
- Click “Create new project”
Project creation takes 2-3 minutes. You’ll receive an email when it’s ready.
Configure authentication
DoctorSoft+ uses Supabase Auth with email/password authentication and PKCE flow for enhanced security.Enable email authentication
- Go to Authentication > Providers in your Supabase dashboard
- Ensure Email provider is enabled
- Configure email settings:
- Enable email confirmations: Recommended for production
- Secure email change: Enable to require verification
- Disable email signups: Configure based on your user management strategy
Configure auth settings
In Authentication > Settings, configure:
- Site URL: Your production application URL (e.g.,
https://doctorsoft.app) - Redirect URLs: Add allowed callback URLs for your application
- JWT expiry: Default is 3600 seconds (1 hour)
- Refresh token rotation: Enable for better security
Session management
DoctorSoft+ implements automatic session refresh and expiration handling:
- Sessions are stored in
localStoragewith SSR-safe fallbacks - Tokens are automatically refreshed when nearing expiration (60 seconds)
- Custom timeout of 15 seconds for all Supabase requests
~/workspace/source/src/lib/supabaseUtils.ts:4-62 for session validation logic.Set up storage buckets
DoctorSoft+ uses Supabase Storage for patient documents, medical images, and other files.Create storage bucket
- Navigate to Storage in your Supabase dashboard
- Click “Create a new bucket”
- Configure the bucket:
- Name:
00000000-default-bucket(or your preferred bucket name) - Public bucket: Disable (patient data must be private)
- File size limit: 10 MB (configurable via
VITE_MAX_FILE_SIZE_MB) - Allowed MIME types: Configure based on your needs (images, PDFs, etc.)
- Name:
Configure environment variables
Set up environment variables for your application.Local development
Create a.env file in your project root:
VITE_SUPABASE_DETECT_SESSION_IN_URL is disabled by default for better performance. Enable it only if you’re using OAuth providers.Production deployment
Add these environment variables to your deployment platform:Client configuration
The Supabase client is configured in~/workspace/source/src/supabase.ts with the following features:
Singleton pattern
The client uses a singleton pattern to prevent multiple instances in development:Custom fetch with timeout
All requests include a 15-second timeout with detailed error messages:SSR-safe storage
Custom storage implementation handles server-side rendering gracefully:Verify your setup
After configuration, verify everything works:Test database connection
Run a simple query in the Supabase SQL Editor:You should see appointment status records if migrations have been applied.
Test authentication
- Start your development server:
npm run dev - Navigate to the login page
- Create a test user account
- Verify you can log in and access protected routes
Next steps
Database migrations
Learn how to apply and manage database schema changes
Security policies
Understand RLS policies and authentication security