Environment variables
What's the intended method to access environment variables in Start in isomorphic code like createRouter?
(import.meta as any).env.VITE_MY_URL
works on the client and server and import.meta.MY_URL
and process.env.VITE_MY_URL
don't.13 Replies
wise-white•13mo ago
@Maintainer - Router we need to build a solution for type safe env vars like Astro.
I believe nitro handles the compatibility to all of the hosting providers.
foreign-sapphire•13mo ago
foreign-sapphire•13mo ago
manually defining an
env.d.ts
?wise-white•13mo ago
Yep. We basically need to clone that page and functionality
import.meta.env is where stuff will live. Not process. (AFAIK)
@ballingt I would refer to astros docs and if something there doesn’t work in Start, then file an issue
passive-yellow•13mo ago
Integrate with t3-env?
wise-white•13mo ago
What’s that?
vicious-gold•13mo ago
GitHub
GitHub - t3-oss/t3-env
Contribute to t3-oss/t3-env development by creating an account on GitHub.
vicious-gold•13mo ago
tl;dr, zod wrapper for env vars that validates at build and runtime
wise-white•13mo ago
That’s cool
loud-coral•13mo ago
I've been trying
And they both come back as undefined in a
beforeLoad
on a router file - not sure if that's a start
issue.extended-salmon•12mo ago
GitHub
Allow type safe access to env (+ show nice errors on
.env
not set...There is Discord thread regarding this feature request too but it got forgotten about thus opening discussion/issue here. Essentially it would be great to have type safe access to the env. Similar ...
extended-salmon•12mo ago
opened issue regarding above feature request
I do want type safe env access too a lot as I was bit by not having it just now
ambitious-aqua•12mo ago
you can add it yourself easily
in your project