Skip to content

validate required environment variables at startup#28

Open
Harushii16 wants to merge 1 commit intoOpen-Source-Chandigarh:masterfrom
Harushii16:feat/env-validation
Open

validate required environment variables at startup#28
Harushii16 wants to merge 1 commit intoOpen-Source-Chandigarh:masterfrom
Harushii16:feat/env-validation

Conversation

@Harushii16
Copy link
Copy Markdown

@Harushii16 Harushii16 commented Oct 9, 2025

Fixes #
Adds startup validation for required environment variables.

✨ What’s New

  • Added src/utils/env.js to validate key environment variables:
    • VITE_SUPABASE_URL
    • VITE_SUPABASE_ANON_KEY
    • (optional) MONGODB_URI
  • Imported the validator at the top of src/main.jsx so checks run immediately before app mounts.
  • If variables are missing or invalid, a clear red overlay appears in the browser with a helpful message.
  • Prevents cryptic runtime errors and helps new contributors set up .env correctly.

🚀 Why This Change

This improves developer experience by ensuring missing or incorrect environment variables are caught early.
Contributors can quickly identify setup issues without digging through console errors.

🧪 How to Test

  1. Run npm run dev
  2. If .env is missing or values are invalid, you'll see a red overlay + console error.
  3. Add proper values in .env (based on .env.example), restart — app starts normally.

🏷️ Hacktoberfest

This contribution is part of Hacktoberfest 2025 🎉
It’s a genuine enhancement that improves the project’s reliability and developer onboarding.
Kindly label this PR as hacktoberfest-accepted if it meets contribution guidelines.

✅ Summary

  • Environment validation added
  • Overlay UI for clear feedback
  • No additional dependencies required
  • Tested locally
  • Ready for review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant