Step-by-step guide to deploy Roost’s frontend on Netlify. The backend must be deployed separately.
Prerequisites
- A Netlify account
- A GitHub/GitLab repository with your Roost project
- Backend deployed separately (VPS, Railway, Render, etc.)
- Database configured (Supabase Cloud recommended)
Step 1: Push to Git
git init
git add .
git commit -m "Initial Roost setup"
git remote add origin https://github.com/your-org/roost.git
git push -u origin main
Step 2: Import to Netlify
Via Netlify Dashboard
- Go to app.netlify.com
- Click Add new site > Import an existing project
- Choose your Git provider and select the
roostrepository - Configure build settings:
- Branch to deploy:
main - Build command:
npm run build - Publish directory:
dist
- Branch to deploy:
- Click Deploy site
Via Netlify CLI
# Install Netlify CLI
npm install -g netlify-cli
# Login
netlify login
# Initialize
netlify init
# Deploy
netlify deploy --prod
Step 3: Configure Environment Variables
Go to Site settings > Environment variables and add:
| Variable | Value |
|---|---|
VITE_DB_PROVIDER |
supabase-cloud |
VITE_SUPABASE_URL |
https://your-project.supabase.co |
VITE_SUPABASE_PUBLISHABLE_KEY |
your-anon-key |
VITE_APP_NAME |
Your Community |
VITE_APP_URL |
https://your-site.netlify.app |
VITE_API_URL |
https://your-backend-url.com |
VITE_ENABLE_SIGNUP |
true |
NODE_VERSION |
20 |
After adding variables, trigger a redeploy: Deploys > Trigger deploy > Deploy site.
Step 4: Custom Domain (Optional)
- Site settings > Domain management > Add custom domain
- Enter your domain (e.g.,
roost.your-domain.com) - Update DNS records:
- CNAME:
your-site.netlify.app - Or use Netlify DNS for automatic configuration
- CNAME:
- SSL is provisioned automatically via Let’s Encrypt
Update your env var:
VITE_APP_URL=https://roost.your-domain.com
Step 5: Deploy the Backend
Same options as the Vercel guide — the backend needs a separate host:
Railway
cd server
railway login && railway init && railway up
Render
- New > Web Service > Connect repo
- Root directory:
server - Build:
npm install && npm run build - Start:
npm start
VPS with PM2
cd server && npm install && npm run build
pm2 start dist/index.js --name roost-backend
Step 6: Update CORS
In your backend server/.env:
ALLOWED_ORIGINS=https://your-site.netlify.app,https://roost.your-domain.com
FRONTEND_URL=https://roost.your-domain.com
Netlify Configuration
The netlify.toml is already configured:
[build]
command = "npm run build"
publish = "dist"
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
[[headers]]
for = "/assets/*"
[headers.values]
Cache-Control = "public, max-age=31536000, immutable"
The redirect rule ensures SPA routing works. Asset caching is set to 1 year for optimal performance.
Deploy Previews
Netlify automatically creates deploy previews for pull requests:
- Open a PR on GitHub
- Netlify builds and deploys a preview
- A link appears in the PR comments
- Preview uses the same env vars as production (unless overridden)
Build Plugins (Optional)
Lighthouse Plugin
netlify plugins:install netlify-plugin-lighthouse
Automatically runs Lighthouse audits on every deploy.
Cache Plugin
Netlify caches node_modules by default. For faster builds, you can also cache the Vite build cache:
Add to netlify.toml:
[[plugins]]
package = "@netlify/plugin-caching"
[plugins.inputs]
paths = ["node_modules/.vite"]
Troubleshooting
Build fails
- Check build logs in Deploys tab
- Ensure
NODE_VERSION=20is set in environment variables - Verify all
VITE_*env vars are configured
404 on page refresh
- Ensure the
[[redirects]]rule is innetlify.toml - Or add a
public/_redirectsfile with:/* /index.html 200
API calls fail
- Check CORS settings on your backend
- Verify
VITE_API_URLpoints to your backend - Test with:
curl https://your-backend-url.com/api/health
Environment variables not working
- Variables must start with
VITE_to be available in the frontend - Redeploy after changing variables