Open amirfakhrullah opened 1 year ago
Hi! I was running into the same problem. There's indeed tedious to have env variable validation in multiple packages and if you want to use the same env variable in another package, you have to run validation again.
My question is: Why should packages/auth
and packages/api
have env variables in the first place? They are packages, not runnable applications. In the same way you download a package from npm, it will not read your .env file, instead you give it variables as parameters.
Personally, I would rather have packages more pure, and only have env variables in the expo
and nextjs
application. Then pass them on as parameters to other packages.
For Example in apps/nextjs/src/pages/api/trpc/[trpc].ts
we can pass all config as parameters to a factory method:
Any suggestions or ideas @juliusmarminge ?
Personally, I would rather have packages more pure, and only have env variables in the expo and nextjs application. Then pass them on as parameters to other packages.
I'd like that too, however I'm not sure how to implement that in a nice way. Open for PRs!
I don't want a separate @acme/env
package. Either the package itself validates what it needs, or we keep envs in the apps and only validate there
I thought about this as well while dealing with envs. I agree with @cjkihl that it is better if we only have env variables in the expo
and nextjs
applications.
I've also ran into this issue replacing the @vercel/postgres
package with a generic postgres package in Drizzle. I honestly think the best bet is creating an acme/env package, I'm curious as to why you're against it @juliusmarminge
wondering why packages/db doesn't validate env but packages/auth does @juliusmarminge
Describe the feature you'd like to request
From the template, we're using
t3-env
validations separately inapps/nextjs
andpackages/auth
. If I want to use the environment variables inpackages/api
then I need to set upt3-env
validations separately for that workspace. This looks like a duplicated code and I think we should refactor it.Describe the solution you'd like to see
I suggest to put the
t3-env
validations inpackages/config
or in a new workspace, then other workspaces likeapps/nextjs
,packages/db
,packages/auth
andpackages/api
can just import it whenever they want to use them.Additional information
I would love to work on this if you guys agree to pick this up
Similar issue - https://github.com/t3-oss/create-t3-turbo/issues/385