This guide covers deploying the Pastry Palace React app to production with proper environment configuration.
- All environment variables configured
-
.env.localis in.gitignore(never commit secrets) - Tested in development mode locally
- All features working with real Supabase & Telegram
- Build passes without errors (
npm run build)
-
Copy
.env.exampleto.env.local:cp .env.example .env.local
-
Fill in your credentials:
REACT_APP_SUPABASE_URL=your-supabase-url REACT_APP_SUPABASE_ANON_KEY=your-anon-key REACT_APP_TELEGRAM_BOT_TOKEN=your-bot-token REACT_APP_TELEGRAM_CHAT_ID=your-chat-id
-
Run dev server:
npm start
-
Build the app:
npm run build
-
The
build/folder contains the production-ready files
Easiest deployment with automatic environment variables.
-
Push code to GitHub:
git add . git commit -m "Ready for deployment" git push
-
Go to vercel.com and import your repository
-
Add environment variables in Vercel dashboard:
REACT_APP_SUPABASE_URLREACT_APP_SUPABASE_ANON_KEYREACT_APP_TELEGRAM_BOT_TOKENREACT_APP_TELEGRAM_CHAT_ID
-
Vercel will automatically build and deploy
-
Build locally:
npm run build
-
Go to netlify.com and drag-drop the
buildfolder, OR connect your GitHub repo -
Add environment variables in Netlify dashboard under Site Settings → Build & Deploy → Environment
-
Redeploy for changes to take effect
-
Add to
package.json:"homepage": "https://yourusername.github.io/bakery"
-
Install
gh-pages:npm install --save-dev gh-pages
-
Add deploy scripts to
package.json:"scripts": { "predeploy": "npm run build", "deploy": "gh-pages -d build" }
-
Deploy:
npm run deploy
Note: Environment variables won't be available on GitHub Pages (it's static). Use Vercel or Netlify for dynamic features.
-
Create
Dockerfile:FROM node:18-alpine as build WORKDIR /app COPY package*.json ./ RUN npm install COPY . . ARG REACT_APP_SUPABASE_URL ARG REACT_APP_SUPABASE_ANON_KEY ARG REACT_APP_TELEGRAM_BOT_TOKEN ARG REACT_APP_TELEGRAM_CHAT_ID ENV REACT_APP_SUPABASE_URL=$REACT_APP_SUPABASE_URL ENV REACT_APP_SUPABASE_ANON_KEY=$REACT_APP_SUPABASE_ANON_KEY ENV REACT_APP_TELEGRAM_BOT_TOKEN=$REACT_APP_TELEGRAM_BOT_TOKEN ENV REACT_APP_TELEGRAM_CHAT_ID=$REACT_APP_TELEGRAM_CHAT_ID RUN npm run build FROM nginx:alpine COPY --from=build /app/build /usr/share/nginx/html EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]
-
Build and run:
docker build \ --build-arg REACT_APP_SUPABASE_URL="your-url" \ --build-arg REACT_APP_SUPABASE_ANON_KEY="your-key" \ --build-arg REACT_APP_TELEGRAM_BOT_TOKEN="your-token" \ --build-arg REACT_APP_TELEGRAM_CHAT_ID="your-id" \ -t pastry-palace . docker run -p 80:80 pastry-palace
| Variable | Required | Description | Example |
|---|---|---|---|
REACT_APP_SUPABASE_URL |
Yes | Supabase project URL | https://abc.supabase.co |
REACT_APP_SUPABASE_ANON_KEY |
Yes | Supabase anonymous key | Long JWT token |
REACT_APP_TELEGRAM_BOT_TOKEN |
No* | Telegram bot token | 123456:ABC... |
REACT_APP_TELEGRAM_CHAT_ID |
No* | Telegram chat ID | 7497065699 |
*Telegram is optional - app works without it but won't send notifications
-
Never commit
.envfiles# Already in .gitignore, but verify: git status # Should not show .env.local
-
Rotate credentials periodically
- Regenerate Supabase keys annually
- Recreate Telegram bot tokens if exposed
-
Use separate credentials per environment
- Development:
.env.local - Staging:
.env.staging - Production: Platform-specific (Vercel, Netlify, etc.)
- Development:
-
Restrict Supabase access
- Use Row Level Security (RLS) policies
- Limit API key permissions
- Monitor API usage
-
Secure Telegram bot
- Don't share bot token publicly
- Use a group chat instead of personal chat if sharing notifications
- Monitor message volume
- Test authentication at
/loginand/register - Test feedback submission at
/feedback - Test orders at
/checkout - Test customization at
/customize - Check Telegram for notifications
- Monitor Supabase dashboard for API usage
- Check Telegram for regular message delivery
- Set up error tracking (optional: Sentry, LogRocket)
-
Update dependencies regularly:
npm outdated npm update npm audit fix
-
Test new versions in development first:
npm start
-
Deploy updates:
git add . git commit -m "Update dependencies" git push # Vercel/Netlify auto-deploys
- Check platform-specific environment variable syntax
- Verify variable names are correct (case-sensitive)
- Restart build after adding vars
- For Vercel: Check "Skip Functions for now" is unchecked
- Verify bot token and chat ID
- Check API response in browser console
- Test bot with curl:
curl -X POST https://api.telegram.org/bot{TOKEN}/sendMessage...
- Verify Supabase URL and key
- Check Supabase project is active
- Verify user email is confirmed in Supabase
- Run
npm ciinstead ofnpm installfor CI/CD - Check Node version (requires v16+)
- Clear cache:
npm cache clean --force
- Supabase Docs: https://supabase.com/docs
- Telegram Bot API: https://core.telegram.org/bots/api
- React Docs: https://react.dev