t3-env in a monorepo

When using t3-env in a monorepo where different sub-packages need different parts of the env, is it recommended to create a sub-package specifically for the env and put all of the env vars in there, or for each sub-package to manage its own env?

The issue with the latter is of course that sometimes multiple packages depend on the same env vars, leading to code duplication. The issue with the former approach is that it feels like poor encapsulation and gives packages access to env vars that don't apply to them.
Solution
I would make one env package and then have seperate files that are imported where you need them, here’s how I do it:

https://github.com/AnswerOverflow/AnswerOverflow/tree/main/packages/env
GitHub
Indexing Discord Help Channel Questions into Google - AnswerOverflow/AnswerOverflow
Was this page helpful?