Stop using typescript env variables wrong

  Рет қаралды 9,932

Web Dev Cody

Web Dev Cody

Ай бұрын

env.t3.gg/
My Products
📖 ProjectPlannerAI: projectplannerai.com
🤖 IconGeneratorAI: icongeneratorai.com
📝 ThumbnailCritique: thumbnailcritique.com
Useful Links
💬 Discord: / discord
🔔 Newsletter: newsletter.webdevcody.com/
📁 GitHub: github.com/webdevcody
📺 Twitch: / webdevcody
🤖 Website: webdevcody.com
🐦 Twitter: / webdevcody

Пікірлер: 52
@Mrvituhmincguy
@Mrvituhmincguy Ай бұрын
Thanks for the rec as usual Cody. T3-env has worked well for me in the past
@Stallion45
@Stallion45 22 күн бұрын
I've seen this around but never dug into it. Just dropped it in a project. Very cool. Nice to see the quick overview. I should have used this sooner.
@SaaSLTDDeals
@SaaSLTDDeals Ай бұрын
Wow, such a game-changer! Ensuring type safety for environment variables in Next.js is crucial for seamless deployment. Thanks for the tip!
@luiswebdev8292
@luiswebdev8292 Ай бұрын
super easy to implement! thank you!
@alyahmed7639
@alyahmed7639 Ай бұрын
Great video, but this might break tree shaking, for example let's say you have isProd env variable so webpack will replace this env variables true or false and tree shaking will remove some code based on this values. one major use case if you remember redux :D you can add middlewares for dev but you don't want them in production just an example
@anruntxd8711
@anruntxd8711 Ай бұрын
Wow thank you, I didnt know it existed!
@kaloyangeorgiev6824
@kaloyangeorgiev6824 Ай бұрын
Did I understood correctly? Using this, if on local you have all variables set it will work, but if in production you have missed for example 1 env variable or mispell it, we will get some error?
@cloudeater9571
@cloudeater9571 Ай бұрын
Actually JUST did this type of thing recently. Many projects have limits on getting packages approved so went with a getter for env values, simple check for value and error/log otherwise. Then used the getter for each setting in a config file that the app as a whole uses to reference such values, which allows the config file to be slapped with an interface. That allows us to offset the stack overflow limitations of adding a global d.ts file for ProcessEnv with expected variables. The real kicker is googling how to do generics for the getter because ain’t nobody memorizes how :P
@cloudeater9571
@cloudeater9571 Ай бұрын
Of note, your solution is hands down a better dev experience - kudos
@roach_iam
@roach_iam Ай бұрын
Good video, keep in mind that envs can only be strings, so don't get too carried away with the zod schemas.
@WebDevCody
@WebDevCody Ай бұрын
I think this library automatically parses numbers and booleans as well
@shigu.01
@shigu.01 Ай бұрын
I don't know about t3-env, but you can pass { coerce: true } into a zod number schema
@EduarteBDO
@EduarteBDO Ай бұрын
What if you add a test in the build process that will test all env variables, and a separate ts file that declare the env variables removing the undefined part. Then when building this test can fail and stop the build process. This would remove the dependence need. And you don't need to import {env}, I know This could be worse development experience but it could have some advantages.
@ewwitsantonio
@ewwitsantonio Ай бұрын
Great, thank you! I have video topic suggestion: documentation creation. I'm curious what your insights me be on writing documentation for projects/tools, if that's something you do, and if there are any tools that help you to do so. Thanks!
@WebDevCody
@WebDevCody Ай бұрын
I think I’ve used docsify, swagger also is good for api docs
@ewwitsantonio
@ewwitsantonio Ай бұрын
@@WebDevCody thanks so much!
@jorgesa4244
@jorgesa4244 Ай бұрын
What are you using now instead of t3 stack?
@perc-ai
@perc-ai Ай бұрын
supabase
@ivanbragin7932
@ivanbragin7932 Ай бұрын
Theo approved video
@nhatvominh3387
@nhatvominh3387 Ай бұрын
can someone tell me his extension theme he is using ? thanks you
@Openbyt
@Openbyt Ай бұрын
Hey, what's the VS Code theme you've got going on?
@user-tm1xl4bf7o
@user-tm1xl4bf7o Ай бұрын
did you find??
@user-tm1xl4bf7o
@user-tm1xl4bf7o Ай бұрын
Bearded theme stained blue
@user-jm1qz4dj9l
@user-jm1qz4dj9l Ай бұрын
Can you show all your extensions?
@Support-Phalestine
@Support-Phalestine Ай бұрын
bro can you guide me is it valuable to learn c# .netcore at this time is it worth it or not ??
@WebDevCody
@WebDevCody Ай бұрын
I’ve never had a .net job, but I know there are jobs using both
@Dom-zy1qy
@Dom-zy1qy Ай бұрын
I am assuming .net would be a bit better for job prospects, seems less competitive than js world. I really am just guessing tho.
@Support-Phalestine
@Support-Phalestine Ай бұрын
@@Dom-zy1qy exactly bro that's the point
@AneeshSaravuKarekad
@AneeshSaravuKarekad Ай бұрын
Is environment validation in runtime really necessary just to get type inference? I would rather move the env validation to a build step before deploying. Let me know your thoughts. Great work on the consistency!
@WebDevCody
@WebDevCody Ай бұрын
It’s just a little extra help to consolidate all env variables. I’ve been on apps where the same env variable is imported in like 10 files; this helps centralize the config a bit
@AneeshSaravuKarekad
@AneeshSaravuKarekad Ай бұрын
@@WebDevCody Ah I do suggest having a centralized config file for environment variables, but I don't like running validation on the config in runtime.
@SeibertSwirl
@SeibertSwirl Ай бұрын
Good job babe!
@WebDevCody
@WebDevCody Ай бұрын
😘
@Openbyt
@Openbyt Ай бұрын
Please tell me What is your vs code theme name? Sir
@iiilllii140
@iiilllii140 Ай бұрын
Does it only work with zod? My project uses valibot.
@theklr
@theklr Ай бұрын
They have work in progress to decouple the validator.
@tsykin
@tsykin Ай бұрын
I usually just create utils file where I define and export object with all env.process strings to then reference them in other files. Do you think that's smart or not really?
@WebDevCody
@WebDevCody Ай бұрын
Seems ok to me
@qizhang5749
@qizhang5749 Ай бұрын
I use joi and make a schema for my environment variables
@filipfiser1045
@filipfiser1045 Ай бұрын
Cool package, but I don't know about having so much packages inside my project. I already have a lot.
@plusquare
@plusquare Ай бұрын
typesafe env vars are great until u forgot to update the env vars for CI and that shit breaks anyway
@flyingpanhandle
@flyingpanhandle Ай бұрын
you really don't need multiple third party libs to do this.
@WebDevCody
@WebDevCody Ай бұрын
Multiple? Who uses multiple?
@flyingpanhandle
@flyingpanhandle Ай бұрын
@@WebDevCody 1. T3-env. 2. Zod.
@WebDevCody
@WebDevCody Ай бұрын
@@flyingpanhandle oh I see what you mean
@user-pj4ju1oi1l
@user-pj4ju1oi1l Ай бұрын
@flyingpanhandle Could you give an example without third party libs? Or do you mean only T3-env lib is necessary to achieve something similar.
@theklr
@theklr Ай бұрын
Can you give solutions?
Why I'm learning Go
21:35
Web Dev Cody
Рет қаралды 54 М.
1 класс vs 11 класс (неаккуратность)
01:00
БЕРТ
Рет қаралды 2,3 МЛН
Как быстро замутить ЭлектроСамокат
00:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 2,1 МЛН
WHY DOES SHE HAVE A REWARD? #youtubecreatorawards
00:41
Levsob
Рет қаралды 28 МЛН
This tool makes self hosting simple
5:59
Web Dev Cody
Рет қаралды 52 М.
Thoughts About Unit Testing | Prime Reacts
11:21
ThePrimeTime
Рет қаралды 203 М.
7 Amazing CLI Tools You Need To Try
18:10
Josean Martinez
Рет қаралды 183 М.
You Are Using useEffect Wrong
14:40
Cosden Solutions
Рет қаралды 30 М.
Stop Using the Worst Way to Loop Lists in .NET!
9:35
Nick Chapsas
Рет қаралды 43 М.
Why Rust is NOT a Passing Fad...
8:54
Travis Media
Рет қаралды 24 М.
My favorite component library is unstoppable
4:54
Web Dev Cody
Рет қаралды 19 М.
Vercel Gave Up On Edge
17:50
Theo - t3․gg
Рет қаралды 96 М.
1 класс vs 11 класс (неаккуратность)
01:00
БЕРТ
Рет қаралды 2,3 МЛН