Environment Configuration
React SuperAdmin uses a multi-environment setup to provide different deployment targets for development, testing, and production.
Environment Overview
| Environment | URL | Purpose | Trigger | Firebase Project | Channel |
|---|---|---|---|---|---|
| Production | https://react-superadmin.web.app | Live production site | main branch push | react-superadmin | live |
| Preview | https://react-superadmin.web.app | Feature preview & testing | Pull requests | react-superadmin | pr-{number} |
| Staging | https://react-superadmin.web.app | Pre-production testing | PR with staging label | react-superadmin | staging |
| Local | http://localhost:3000 | Development | Local development | react-superadmin | local |
How It Works
Single Project, Multiple Channels
React SuperAdmin uses a single Firebase project (react-superadmin) with
different deployment channels:
- Production Channel:
live- Deploys to main domain - Preview Channels:
pr-{number}- Deploys to preview URLs (e.g.,pr-68) - Staging Channel:
staging- Deploys to staging environment - Local Channel:
local- For development testing
Each environment has its own:
- URL: Same domain but different channels
- Firebase Project: Single project (
react-superadmin) - Channel ID: Different deployment channels within the project
- Deployment Trigger: Different GitHub events
Configuration Files
Environment Configuration (docs/config/environments.ts)
export const environments = {
production: {
url: 'https://react-superadmin.web.app',
firebaseChannelId: 'live',
},
preview: {
url: 'https://react-superadmin.web.app',
firebaseChannelId: 'preview',
},
staging: {
url: 'https://react-superadmin.web.app',
firebaseChannelId: 'staging',
},
};
GitHub Workflow (.github/workflows/deploy.yml)
jobs:
deploy-docs-production:
environment:
name: production
url: https://react-superadmin.web.app
# Deploys to live channel
deploy-docs-preview:
environment:
name: preview
url: https://react-superadmin.web.app
# Deploys to pr-{number} channel
deploy-docs-staging:
environment:
name: staging
url: https://react-superadmin.web.app
# Deploys to staging channel
GitHub Environments
- Production: Protected environment for main branch deployments
- Preview: Open environment for pull request deployments
- Staging: Open environment for staging deployments (requires
staginglabel)
Deployment Process
Production Deployment
- Push to
mainbranch - Triggers
deploy-docs-productionjob - Deploys to
livechannel - Available at
https://react-superadmin.web.app
Preview Deployment
- Create pull request to
main - Triggers
deploy-docs-previewjob - Deploys to
pr-{number}channel (e.g.,pr-68) - Available at
https://react-superadmin.web.app(same domain, different channel)
Staging Deployment
- Create pull request with
staginglabel - Triggers
deploy-docs-stagingjob - Deploys to
stagingchannel - Available at
https://react-superadmin.web.app(same domain, different channel)
🧹 Cleanup: Removing Old Firebase Project
Previously, React SuperAdmin used two separate Firebase projects:
react-superadmin- Production (short URL)react-superadmin-eb776- Preview (long URL)
This caused confusion and maintenance overhead. We've now consolidated to use only
the react-superadmin project with different deployment channels.
Steps to Clean Up
-
Verify New Setup Works
# Test production deployment
git push origin main
# Test preview deployment
gh pr create --title "Test Preview" --body "Testing preview deployment" -
Remove Old Project (Optional)
# Switch to the old project
npx firebase use react-superadmin-eb776
# List hosting sites
npx firebase hosting:sites:list
# Delete the old project (BE CAREFUL!)
# npx firebase projects:delete react-superadmin-eb776 -
Update Local Development
# Switch back to main project
npx firebase use react-superadmin
# Verify current project
npx firebase projects:list
Troubleshooting
Common Issues
-
Deployment Fails
- Check Firebase service account permissions
- Verify channel ID exists in project
- Check GitHub environment protection rules
-
Wrong Channel Deployed
- Verify
channelIdin workflow matches environment - Check environment detection logic
- Ensure correct branch/PR triggers
- Verify
-
URL Not Accessible
- Wait for DNS propagation (can take up to 24 hours)
- Check Firebase hosting status
- Verify channel configuration
Environment Detection
The system automatically detects the environment based on:
- CI:
process.env.CI === 'true' - Production:
GITHUB_REF === 'refs/heads/main' - Preview:
GITHUB_REFexists but not main - Local: None of the above
Best Practices
- Always test in preview before merging to main
- Use staging environment for major changes
- Monitor deployment logs for any issues
- Keep environment URLs consistent across configs
- Use descriptive channel names for easy identification
Channel URLs
With Firebase Hosting channels, you can access different environments:
- Production:
https://react-superadmin.web.app - Preview:
https://react-superadmin--pr-68.web.app(for PR #68) - Staging:
https://react-superadmin--staging.web.app - Local:
https://react-superadmin--local.web.app
The channel URLs follow the pattern: {project-id}--{channel-id}.web.app
Remember to always test environment changes in preview before applying to production!