Type-Safe .env Validation with Envalid | Environment Variables

  Рет қаралды 13,168

Dave Gray

Dave Gray

Күн бұрын

Web Dev Roadmap for Beginners (Free!): bit.ly/DaveGra...
Type-Safe .env Validation with Envalid | Environment Variables
Learn how to use the Envalid package to validate the environment variables from your .env or .env.local file for maximum type-safety.
Envalid: www.npmjs.com/...
🚩 Subscribe ➜ bit.ly/3nGHmNn
📬 Course Updates ➜ courses.davegr...
❓ Questions - Please post them to my Discord ➜ / discord
☕ Buy Me A Coffee ➜ www.buymeacoff...
👇 Follow Me On Social Media:
GitHub: github.com/git...
Twitter: / yesdavidgray
LinkedIn: / davidagray

Пікірлер: 16
@amitei1183
@amitei1183 Жыл бұрын
I think what you could also do for bigger projects is assert env variables at the root of your application with any validator (like zod). And even parse some of variables like numbers, enums or any other type if you want to. After that you could extend process.env types in .d.ts file with respective types and be safe whenever you use them.
@farahrayis5928
@farahrayis5928 Жыл бұрын
You always have such great content on your channel. Thank you.
Жыл бұрын
Does this create any security risks?
@webapple1
@webapple1 Жыл бұрын
am i the only one thinking , why? envs will always be a string esp a api key? feels like adding a layer for no reason to validate something that will always be x and not y.
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
Unless you forget to add them and then they are undefined. This can easily happen when you deploy.
@georgesword2012
@georgesword2012 Жыл бұрын
Nice 👍
@randomdeathafterplannedbir3386
@randomdeathafterplannedbir3386 Жыл бұрын
neat!
@js-dev8682
@js-dev8682 Жыл бұрын
that make risk someone know what kind of env defined by this env method
@acemav
@acemav Жыл бұрын
Yum..keys will be shared worldwide
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
As always if put in a frontend component. I would advise using server components.
@monq02
@monq02 Жыл бұрын
now we need .tenv a type safe .env 😂
@artyomtaranenko2267
@artyomtaranenko2267 Жыл бұрын
I think we can use zod
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
You can. It's ok to have more than one option.
@pikachu5223
@pikachu5223 Жыл бұрын
😴😴😴😴😴😴😴
How Did I Not Know This TypeScript Trick Earlier??!
9:11
Josh tried coding
Рет қаралды 212 М.
This Took Me 150 Hours to Code
16:40
Kenny Gunderman
Рет қаралды 182 М.
OYUNCAK MİKROFON İLE TRAFİK LAMBASINI DEĞİŞTİRDİ 😱
00:17
Melih Taşçı
Рет қаралды 12 МЛН
POV: Your kids ask to play the claw machine
00:20
Hungry FAM
Рет қаралды 21 МЛН
Inside Out 2: BABY JOY VS SHIN SONIC 3
00:19
AnythingAlexia
Рет қаралды 8 МЛН
Node.js Doesn’t Suck Anymore
16:59
Web Dev Simplified
Рет қаралды 111 М.
Typescript Basic Types - Beginners Lesson
16:16
Dave Gray
Рет қаралды 20 М.
We Fixed Environment Variables
7:27
Theo - t3․gg
Рет қаралды 63 М.
as const: the most underrated TypeScript feature
5:38
Matt Pocock
Рет қаралды 119 М.
Junior vs Senior React Folder Structure - How To Organize React Projects
16:16
Roasting Your Dev Portfolio Sites | Livestream highlight
19:24
Anthony Sistilli
Рет қаралды 80 М.
Modern Data Fetching in React (Complete Guide)
16:41
Cosden Solutions
Рет қаралды 48 М.
Thoughts About Unit Testing | Prime Reacts
11:21
ThePrimeTime
Рет қаралды 225 М.
My FAVORITE Error Handling Technique
16:01
ArjanCodes
Рет қаралды 37 М.
Moving back to JavaScript after my Elixir journey
15:46
Daniel Berg
Рет қаралды 3,7 М.
OYUNCAK MİKROFON İLE TRAFİK LAMBASINI DEĞİŞTİRDİ 😱
00:17
Melih Taşçı
Рет қаралды 12 МЛН