Prerequisites
Before deploying to Netlify, ensure you have:- A Netlify account (sign up for free)
- Your code in a Git repository (GitHub, GitLab, or Bitbucket)
- Supabase project URL and anon key
- All required environment variables ready
Deployment steps
Connect your repository
- Log in to Netlify
- Click “Add new site” > “Import an existing project”
- Choose your Git provider (GitHub, GitLab, or Bitbucket)
- Authorize Netlify to access your repositories
- Select the DoctorSoft+ repository
Configure build settings
On the build settings page, configure the following:
| Setting | Value |
|---|---|
| Branch to deploy | main (or your primary branch) |
| Build command | npm run build |
| Publish directory | dist |
| Node version | 18 or higher |
Netlify will automatically detect that this is a Vite project and may pre-fill these settings.
Add environment variables
Before deploying, add all required environment variables:
- In the deployment configuration screen, scroll to “Environment variables”
- Click “Add environment variables”
- Add the following required variables:
Deploy
- Click “Deploy site”
- Netlify will clone your repository and start the build process
- Monitor the build logs for any errors
- Once complete, your site will be live at a Netlify subdomain (e.g.,
random-name-123.netlify.app)
Environment variable configuration
If you need to add or update environment variables after deployment:Navigate to environment settings
- Go to your site in the Netlify dashboard
- Click “Site settings”
- Navigate to “Build & deploy” > “Environment”
Add or edit variables
- Click “Add a variable” or “Edit” next to an existing variable
- Enter the variable name and value
- Click “Save”
SPA routing configuration
DoctorSoft+ is a single-page application (SPA) that uses client-side routing. Netlify needs to redirect all requests toindex.html to handle routes properly.
The build process automatically generates a
_redirects file in the dist folder to handle SPA routing._redirects file exists in your dist folder after building:
Build settings via netlify.toml
For more control, you can create anetlify.toml file in your repository root:
Environment variables should still be configured in the Netlify dashboard, not in
netlify.toml, as this file is committed to version control.Continuous deployment
Netlify automatically deploys your site whenever you push to your configured branch:- Automatic builds: Every push to the main branch triggers a new deployment
- Deploy previews: Pull requests generate preview deployments with unique URLs
- Build notifications: Get notified via email or Slack when deployments succeed or fail
Configure deploy contexts
You can set different environment variables for production and deploy previews:- Go to Site Settings > Build & Deploy > Environment
- Click on an environment variable
- Select which contexts it applies to:
- Production
- Deploy Previews
- Branch deploys
Monitoring and logs
Build logs
To view build logs:- Go to the “Deploys” tab
- Click on any deployment
- View the full build log
Function logs (if using Netlify Functions)
If you add Netlify Functions later:- Go to the “Functions” tab
- Click on a function to view logs
- Monitor real-time invocations and errors
Troubleshooting
Build fails with “Command failed with exit code 1”
Common causes:- Missing environment variables
- TypeScript errors in code
- Dependency installation failures
- Check the build logs for specific error messages
- Verify all required environment variables are set
- Ensure
package.jsonandpackage-lock.jsonare committed - Try building locally:
npm run build
Blank page after deployment
Common causes:- Missing
_redirectsfile - Environment variables not set
- JavaScript errors in production build
- Check browser console for errors
- Verify environment variables in Site Settings
- Ensure
_redirectsfile is in thedistfolder - Test production build locally:
npm run build && npm run preview
404 errors on routes
Common causes:- SPA redirects not configured
- Missing
_redirectsfile
- Verify
_redirectsfile exists indistfolder with content:/* /index.html 200 - Add redirect configuration to
netlify.toml(see above) - Clear Netlify cache and redeploy
Environment variables not working
Common causes:- Variables set for wrong deploy context
- Forgot to redeploy after adding variables
- Variable names missing
VITE_prefix
- Verify variables are set for the correct context (Production/Preview)
- Trigger a new deployment after adding variables
- Ensure all variables start with
VITE_ - Check build logs for environment variable warnings
Performance optimization
Netlify automatically provides:- Global CDN: Assets served from edge locations worldwide
- Asset optimization: Automatic image optimization (with Netlify Pro)
- HTTP/2: Modern protocol for faster loading
- Gzip/Brotli compression: Automatic compression of text assets
Additional optimizations
-
Enable asset optimization (Netlify Pro):
- Go to Site Settings > Build & deploy > Post processing
- Enable “Bundle CSS” and “Minify JS and CSS”
-
Configure caching headers via
netlify.toml: -
Enable Netlify Analytics to monitor performance:
- Go to Site Settings > Analytics
- Enable Netlify Analytics
Next steps
Environment Variables
Learn about all available environment variables
Deployment Overview
Back to deployment overview
Netlify Documentation
Official Netlify documentation
Custom Domains
Configure custom domains and SSL