mwskwong/mwskwong.com

Explore using Valibot to validate environment variables directly without using T3 Env

Closed this issue · 0 comments

T3 Env doesn't support Valibot and doesn't seem to happen any time soon. Let's see if I can do so (and how complicated it will be) without the library.

How can I include and validate both client and server env vars in one single file, without getting complaints about server variables cannot be accessed on the client side?

What about if I just validate all env vars in built time (e.g. in next.config.ts) and then declare the env var types here?

declare global {
  namespace NodeJS {
    interface ProcessEnv {
      NEXT_PUBLIC_STRIPE_PUBLIC_KEY: string;
    }
  }
}