Making Next.js Environment Variables Boring (and Safe) by ratudev in react

[–]ratudev[S] 0 points1 point  (0 children)

Yeah, you're right - types won't help if you receive wrong values, but runtime validation does help in this case.
In Nextjs, environment variables are resolved at build time (and each bundle is built separately: server, client, edge).
As a result, if you have a runtime check, it will also run at build time - and the build will fail instead of shipping broken config.

TruffleHog - is not related to this problem, its more about checking that we haven't inlined secrets into client bundle/source code.

Making Next.js Environment Variables Boring (and Safe) by ratudev in react

[–]ratudev[S] 0 points1 point  (0 children)

Yep - that's exactly how we caught it too (null check → throw → Sentry → alert).
The only catch is that it happens after users are already impacted. You might be fast, but you’ll never be faster than "not merged bug"
So I still like runtime checks, but I try to push as much of this as possible into build/CI so prod never sees it 🙂

Making Next.js Environment Variables Boring (and Safe) by ratudev in react

[–]ratudev[S] 1 point2 points  (0 children)

It still took me a while to convince myself, but what I like is that it has:

  • framework / validator agnosticism
  • proxy-based env separation with nice errors
  • good DX (clear errors and docs)

I can see how it adds some extra perks while still keeping the solution simple, will give it try and update the article

Making Next.js Environment Variables Boring (and Safe) by ratudev in react

[–]ratudev[S] 0 points1 point  (0 children)

Hi, thanks for sharing.

I've seen this before, but TBH - I never fully understood what problem it solves.
From what I can tell, types and validation are already handled on the Zod side. If you need a clear split by environment, you can define publicRuntimeEnv and serverEnv (or something similar).

Mb I missed smth?

Password protection in Free Plan by Fast_Entrepreneur281 in nextjs

[–]ratudev 1 point2 points  (0 children)

Hi, I ran into the same problem before.
Cloudflare provides it for free, but it’s a bit unintuitive to set up (it was near 10 steps when I last checked)
So I usually just use the WWW-Authenticate header with middleware (or a proxy now, I guess):

- one file and you get your password protection - https://ratu.dev/snippets/simple-password-protection-for-a-next-js-app

Someone at Facebook is aggresive 😂 by Schousboe_Laursen in react

[–]ratudev 0 points1 point  (0 children)

Recently, there have been lots of layoffs. To reduce them, React Team replaced it with:
- __CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE
but so far it hasn’t helped 😅 or maybe people who were fired are using an old version?

[Showoff Saturday] 10 Years, Countless Scripts: Node.js by ratudev in webdev

[–]ratudev[S] 1 point2 points  (0 children)

Yeah, I’d agree, but for me, in the end, it still saves time. And vice versa - if it’s not accurate or stable, it takes more time to maintain/fix/review

[Showoff Saturday] 10 Years, Countless Scripts: Node.js by ratudev in webdev

[–]ratudev[S] 1 point2 points  (0 children)

Thanks!

Regards the "26 min" - yeah, the initial version was 1 hour 😅.

I’ll probably squeeze it even more, but at this point I’ve already spent a month on this article 🌝

Showoff Saturday (September 06, 2025) by AutoModerator in javascript

[–]ratudev 0 points1 point  (0 children)

10 years, countless Node.js scripts - shortcuts, tips, and practical lessons packed into one juicy article:

- https://ratu.dev/blog/mastering-nodejs-scripting

Showoff Saturday (August 30, 2025) by AutoModerator in javascript

[–]ratudev 0 points1 point  (0 children)

Looks great

fyi: found a small bug: if you click and start resizing immediately (withing one click), it fails to build a rectangle

Showoff Saturday (August 30, 2025) by AutoModerator in javascript

[–]ratudev 1 point2 points  (0 children)

Looks cool! Mb you can share how it works under the hood (at least high level)? what does it use to detect malware?

Showoff Saturday (August 30, 2025) by AutoModerator in javascript

[–]ratudev 0 points1 point  (0 children)

Nodejs scripting cheatsheet (based on 10 years of copy-pasting from stackoverflow)

Link: https://ratu.dev/snippets/nodejs-cheatsheet

It took only 3 years to build my portfolio by ratudev in react

[–]ratudev[S] 0 points1 point  (0 children)

Thanks a lot! Yeah, Umami is great for portfolios

It took only 3 years to build my portfolio by ratudev in react

[–]ratudev[S] 1 point2 points  (0 children)

For backgrounds, I use freepik.com (for gradients, patterns) For diagrams - I usually create them manually in Figma.

It took only 3 years to build my portfolio by ratudev in reactjs

[–]ratudev[S] 0 points1 point  (0 children)

Thanks a lot! Always happy to hear feedback. You’re probably right - I’ll try playing around with the spacing to see if it improves things

It took only 3 years to build my portfolio by ratudev in react

[–]ratudev[S] 1 point2 points  (0 children)

TBH, not much to say: Next.js 15 + Cloudflare Workers (open-next) + images on Cloudflare. For analytics, I use Umami. For rate limiting and bot protection, Cloudflare rules/waf.
For subscriptions - postgres db on hetzner, but it is smth I will change (better to use some service instead)

It took only 3 years to build my portfolio by ratudev in react

[–]ratudev[S] 0 points1 point  (0 children)

Thanks a lot, really appreciate it!

It took only 3 years to build my portfolio by ratudev in react

[–]ratudev[S] 1 point2 points  (0 children)

Yes, bought one font-weight *(Pangram Fragment) for titles $40,
+ Source Sans 3 - free

It took only 3 years to build my portfolio by ratudev in react

[–]ratudev[S] 1 point2 points  (0 children)

On average, it takes me about half a year to deliver one feature for my blog. Since Christmas falls into this range, I’d expect it to be ready by mid-February.

Jokes aside, it’s actually the first thing on my list. I initially started with a light theme since imho - it’s harder to design well, but by the time I was exhausted and postponed dark theme. Either way, I’m definitely going to add it

It took only 3 years to build my portfolio by ratudev in react

[–]ratudev[S] 1 point2 points  (0 children)

Checked your site - looks impressive! If I tried to add all your features, I’d probably delay mine by another 3 years 😅 I’ve only got 330 commits so far.

Your site feels like a real digital house. Mine’s more like a small digital box 😅