Why env vars matter
An environment variable is a named value that exists in the runtime environment of your app — separate from its source code. When your app needs an API key, a database connection string, or a third-party webhook secret, it reads that value from the environment at startup rather than finding it hardcoded in a file.
This separation matters for two reasons. First, secrets that live in code end up in version control. A single accidental push to a public GitHub repository can expose credentials to the entire internet, and rotation after an exposure is painful. Second, different environments — development on your laptop, staging for QA, production for real users — need different values for the same variable. Environment variables make that switch trivial.
Setting variables in Myndlab
Every Myndlab project has an Environment panel where you define your variables. To access it:
Dev vs production values
Myndlab maintains separate variable stores for Development and Production environments. This lets you use a test Stripe key and a local database URL during development, while your production environment uses live credentials and your cloud database — without any code changes.
When Myndlab pushes a deploy to Vercel or Railway, it injects the Production variables directly into the hosting platform's secret store via their APIs. You never need to copy-paste credentials into a hosting dashboard manually.
Referencing vars in generated code
Myndlab generates code that reads environment variables using each language's idiomatic pattern. Here are the two most common cases:
In a FastAPI (Python) backend, variables are loaded with the standard library:
In a React frontend (Vite), variables must be prefixed with VITE_ to be exposed to the browser bundle. This prefix is a security measure — variables without it are never included in the client-side code, even if they exist in the environment.
In an Express (Node.js) backend, the pattern is similar to Python but uses process.env:
Syncing to GitHub
When Myndlab syncs your project to GitHub, environment variables are handled carefully to prevent accidental exposure:
Rotating a secret
Secret rotation — replacing a compromised or expired credential with a new one — should be done carefully to avoid downtime. Here is the safe sequence to follow in Myndlab: