Environment Configuration
Learn how to configure and validate environment variables for development and production environments.
This boilerplate comes with .env
validation out of the box to prevent accidental use of development values like localhost:3000
in production environments.
How it works
The app/lib/env.ts
file contains validation logic that uses @t3-oss
and zod
to validate environment variables at runtime.
To see this in action, try removing any environment variable from your .env.local
file. The application will throw an error indicating the missing variable.
Furthermore, the next.config.mjs
file includes validation code that checks these environment variables during the build process. This ensures that all required variables are present and correctly formatted before the application can be built.