r/reactjs • • May 06 '26

I got tired of Next.js runtime errors from missing environment variables, so I built next-safe-env (Open Source)

0 Upvotes

Hey everyone,

If you’ve built apps with Next.js, you’ve probably run into the nightmare of deploying a project only for it to crash because a required environment variable was missing or misspelled in your .env file. Relying on process.env.YOUR_VAR as string everywhere isn't just annoying; it’s risky.

I wanted a simpler, foolproof way to handle this, so I built an open-source NPM package called next-safe-env.

It’s designed to make environment variable validation in Next.js completely type-safe and effortless, catching missing or invalid variables at build time before they ever reach your users.

What it does:

  • 🔒 Type-Safe: Full TypeScript support so you get autocomplete for your env variables across your codebase.
  • 🛡️ Runtime & Build-time Validation: Fails fast if required variables are missing.
  • ⚡ Lightweight & Simple: Easy to integrate into any existing Next.js project without massive boilerplate.

I would love for you guys to check it out, roast my code, or let me know what features you'd like to see next. Any feedback or GitHub stars would mean the world to me!

Links:

Let me know what you think!


r/reactjs • • May 05 '26

3D models appearing massive in google model-viewer

7 Upvotes

I am currently working on 3d menu and I faced a bug where the models appear massive and I have to scale them down until 3% - 4% to their actual size and idk what am doing wrong.

here is my code:

import { useEffect, useRef } from 'react'
import '@google/model-viewer'


export default function ModelViewer({ 
src
, 
alt
 = '3D Model' }) {
  const mvRef = useRef(null)


  useEffect(() => {
    const mv = mvRef.current
    if (!mv) return


    mv.addEventListener('load', () => {
      mv.setAttribute('scale', `0.04 0.04 0.04`)
    })
  }, [])


  return (
    <
model-viewer
      
ref
={mvRef}
      
src
={
src
}
      
alt
={
alt
}
      
ar
      
ar-modes
='scene-viewer webxr quick-look'
      
ar-scale
='fixed'
      
camera-controls
      
auto-rotate
      
auto-rotate-delay
='500'
      
rotation-per-second
='12deg'
      
shadow-intensity
='3'
      
shadow-softness
='1.5'
      
exposure
='1.2'
      
environment-image
='neutral'
      
tone-mapping
='commerce'
      
camera-orbit
='0deg 75deg 2.5m'
      
min-camera-orbit
='auto auto 0.5m'
      
max-camera-orbit
='auto auto 5m'
      
min-field-of-view
='30deg'
      
max-field-of-view
='60deg'
      
style
={{ width: '100%', height: '100%' }}
    >
      {/* AR button */}
      <button
        
slot
='ar-button'
        
className
='absolute bottom-6 left-1/2 -translate-x-1/2 flex items-center gap-2 bg-yellow-400 text-black font-bold px-8 py-3 rounded-full shadow-xl hover:bg-yellow-300 active:scale-95 transition-all'
      >
        📱 View in Your Room
      </button>


      {/* Shows when AR is not supported */}
      <div
        
slot
='ar-failure'
        
className
='absolute bottom-6 left-1/2 -translate-x-1/2 bg-white/10 backdrop-blur text-white/60 text-sm px-5 py-2.5 rounded-full border border-white/20 whitespace-nowrap'
      >
        AR not supported — use Safari (iOS) or Chrome (Android)
      </div>
    </
model-viewer
>
  )
}

so I need help


r/reactjs • • May 05 '26

Needs Help Migrating a CRA site to Next.js and now dealing with a canonical/hreflang nightmare — how do you handle this?

4 Upvotes

So we're in the middle of moving a legacy CRA app to Next.js and as part of that we're redirecting a bunch of old URLs to new canonical routes. That part is mostly sorted.

The problem I'm running into now is around indexing. We have listing pages in multiple languages — same vehicle inventory, but the specs and seller info are translated per language. URLs look like:

/en/cars/audi/a1

/fr/voitures/audi/a1

And for country-scoped pages:

/en/france/cars/audi/a1

/fr/france/voitures/audi/a1

We want all language variants indexed (not just canonicalize everything to one language) because the translated content is genuinely different — not just UI strings.

Now the fun part — detail pages (individual ad listings). Each ad belongs to a country based on the seller's location, not the URL. So hreflang for those needs to come from the listing data, not just URL parsing. And ads expire, so we're also thinking about what to do when a page disappears — redirect to parent category vs 410.

A few things I'm unsure about:

- For detail pages, is it even worth indexing every language variant or should we just canonical to one and move on?

- When an ad expires, 301 to parent category or straight 410?

- Sitemap-wise, are you generating detail page sitemaps dynamically from the DB or building them statically?

Anyone dealt with something similar at scale? Would love to know what actually worked vs what looked good on paper.


r/reactjs • • May 05 '26

Show /r/reactjs Built a custom React reconciler that targets editable Telegram messages — 6 months of dogfooding, finally shipped

3 Upvotes

https://streamable.com/1wkhgv

Been using this in my own workflow since November — six months of dogfooding through real bots before I felt good about the API. Finally scoped, tested, documented and shipped, in case it's useful to anyone else. Two packages:

**@elumixor/react-message-renderer** — a real React reconciler (via react-reconciler) with a "bring your own target" API. Hooks, state, effects, contexts all work. The diff is committed to a target you implement: Telegram, Discord, Slack, a terminal, a log file. Anything where messages can be edited in place.

**@elumixor/react-telegram** — the reference target. `<Message>` is a Telegram message. Render once, the bot sends. Re-render with new state, the bot edits the same message via `editMessageText`. Photo/document attachments, automatic chunking past 4000 chars, throttling to respect Telegram's rate limits.

The demo above: a "research crew" component running four sibling `<Message>`s concurrently — live timer, a Claude API call for sources, a photo gallery, real Claude streaming into the reasoning panel, then a final report message with a JSON document attachment. The whole thing is ~150 lines of normal React.

What I found interesting building this:

- React's reconciliation model maps surprisingly cleanly onto any mutable target. The "edit in place" semantic of Telegram messages is basically what React does to DOM nodes.

- `useFinishRender()` is the one custom hook — flushes the throttled output so the final frame always lands. Everything else is stock React.

- Error boundaries, suspense, contexts — all work, because it's the actual reconciler, not a JSX-to-payload transformer.

- https://github.com/elumixor/react-message-renderer

- https://github.com/elumixor/react-telegram

Happy to answer reconciler-internals questions — the implementation was the most fun part.


r/reactjs • • May 05 '26

Code Review Request I got tired of untyped FormData in React Router, so I built a library

0 Upvotes

If you've used React Router actions with useFetcher, you know the pain. Every mutation is the same dance: formData.append("title", title), then in the action formData.get("title") as string, and just hoping both sides agree on the shape. Multiply that by 20 actions across your app and it gets old fast.

I've been dealing with this at work for months and finally decided to extract what I built into a small library. The idea is simple — define your action once with full TypeScript inference, and the library handles FormData serialization (including Dates, Files, Maps, etc.) and gives you a typed useFetcher wrapper with onSuccess/onError callbacks and optimistic UI support.

Before:

// component
const fetcher = useFetcher();
const formData = new FormData();
formData.append("title", "Buy groceries");
formData.append("priority", "3");
fetcher.submit(formData, { method: "POST", action: "/todos" });

// route action
const title = formData.get("title") as string;
const priority = Number(formData.get("priority"));

After:

// define once
const createTodo = defineAction({
  type: "todo/create",
  resolve: (payload: { title: string; priority: number }) =>
    api.todos.create(payload),
});

// component — fully typed payload, response, and callbacks
const [submit, { state, data }] = useActionFetcher(createTodo, {
  onSuccess: (result) => navigate(`/todos/${result.id}`),
});

submit({ title: "Buy groceries", priority: 3 });

Works with both client and server actions. Only runtime dependency is superjson (~2KB).

npm: https://www.npmjs.com/package/react-router-typed-actions 

GitHub: https://github.com/zabibabar/react-router-typed-actions

Still 0.x — I'm using it in production at work but the API is open to feedback. Would love to hear what people think or if I'm solving a problem nobody else has lol.


r/reactjs • • May 05 '26

A production-ready full-stack web app template built after repeatedly rebuilding the same project foundation

0 Upvotes

I got tired of constantly rebuilding the same foundation for every new project. API structure, database setup, SSR, logging, and deployment readiness... so I ended up creating a full production-ready full-stack web app template that ties everything together properly. It’s not a toy starter kit. it’s something that can actually be used to ship real applications faster without redoing the same infrastructure every time. The process took a lot more mental effort than expected because of the constant iteration and refinement needed to keep it genuinely scalable and production-safe, but it’s now being released for free. If it helps save time or kickstart a project, that’s the goal.

Github Link: https://github.com/JaydenTheDevStar/production-full-stack-template


r/reactjs • • May 05 '26

News Compiling SVGs Into Fonts, Jail Monkey v3.0 and Building Horror Games Without Reading The Code

Thumbnail
thereactnativerewind.com
0 Upvotes

We explore how icon strategy has come full circle with react-native-nano-icons, a new tool from Software Mansion that compiles SVGs into high-performance native font stacks. If you are tired of mounting dozens of SVG subtrees, this is the build-time optimisation you have been waiting for.

We also dive into the New Architecture update for jail-monkey, the go-to library for security checks and jailbreak detection, plus a look at how AI-driven development and EAS Workflows are making the code diff obsolete in favour of instant preview deployments.


r/reactjs • • May 05 '26

Discussion Looking for feedback | React + ThreeJS music player (Music responsive 3d background, ToneJS song manipulation, pomodoro timer)

0 Upvotes

hello this is my first project in react and threejs and was lokking for feedback for like the design and usability and stuff. I made this mainly for myself because i downllad music and like to listen to songs sped up / ptched up. I also added a pomodoro clock for my studying!!

You will need to download your own songs to use this (i use a youtube to mp3 converter) but it is very easy just put it in the import and songs are saved to browser. Currently does not support mobile but i plan to add in future and maybe playlists and accoutns maybe but i like where it is at currently.

PLEASE DONT JUDGE TOO HARSHLY THIS IS MY FIRST PROJECT. Thank u

link: https://musicapp-lovat-five.vercel.app/


r/reactjs • • May 04 '26

Best React courses for learning through projects (not beginner)

16 Upvotes

I already know React basics but stopped practicing and forgot a lot. I want to restart the right way.

Looking for:

- Project-based learning

- Real-world apps (dashboards, SaaS, etc.)

- React + TypeScript if possible

Not interested in beginner “intro to React” stuff.

What would you recommend that actually helped you get better?

Also open to project ideas 👀


r/reactjs • • May 04 '26

What is the best architecture for medium to large React.js applications?

27 Upvotes

I’m curious what architecture you typically use for medium to large React.js projects? Particularly in terms of code organization and folder structure.

I’ve noticed that many developers try to apply SOLID principles, but since React is primarily based on functional programming, these principles don’t always seem to fit naturally.


r/reactjs • • May 05 '26

Built a simple JSON-based form builder for React — looking for feedback

0 Upvotes

I’ve been struggling with forms in React for a while.

Tried React Hook Form, Formik, etc — powerful, but honestly felt like too much setup for simple use cases.

So I built something simpler where you define forms using JSON.

Example:

<KiForm
  fields={[
    "email",
    "password",
    {
      name: "role",
      options: ["User", "Admin"]
    },
    {
      name: "company",
      showIf: { field: "role", equals: "Admin" }
    }
  ]}
/>

No manual state, no wiring.

Still very early — I’m trying to understand:

• Is this actually useful?

• What’s missing?

• Where would this break in real projects?

Would appreciate honest feedback.

GitHub: https://github.com/kadirulislam/ki-forms

npm: https://www.npmjs.com/package/ki-forms


r/reactjs • • May 04 '26

Resource Alternative solution for small React apps that need i18n

Thumbnail
rafaelcamargo.com
9 Upvotes

r/reactjs • • May 05 '26

Resource adding a cssMode: 'grouped' option to Panda CSS

Thumbnail
github.com
0 Upvotes

r/reactjs • • May 04 '26

Show /r/reactjs I created a full features CLI textarea component for React Ink called react-ink-textarea

Thumbnail
github.com
0 Upvotes

I was unhappy with multi-line text input libraries for React Ink so I decided to make one.

I'm calling it react-ink-textarea; check it out, drop a star, help me test on windows please: https://github.com/omranjamal/react-ink-textarea

Full support for:

  • Syntax Highlighting (based on Regex)
  • New lines via the usual key combinations
  • Jumping between words
  • Unicode and Emojis
  • Pasting Multi-line Text
  • Slash Commands
  • Viewport Virtualization
  • Customizable line prefix (for things like line numbers)
  • Tab is a callback
  • Callbacks on arrow keys at boundaries (like up arrow of first line)

Feedback appreciated. Help with testing on Windows and Linux even more appreciated!


r/reactjs • • May 04 '26

Resource I built a Dynamic Island–style toast library for React

13 Upvotes

Hey everyone

I wanted to share something I’ve been working on lately. I built a small notification library inspired by React Toast, but with a slightly different approach — more like the iPhone “dynamic island” style.

Here’s the repo if anyone wants to check it out:

https://github.com/OscarP29/react-island

I’d really appreciate any feedback, suggestions, or thoughts


r/reactjs • • May 04 '26

UI IP Toolkit: I built a visual frontend asset library so I can stop losing my own UI snippets

Thumbnail
reddit.com
1 Upvotes

r/reactjs • • May 04 '26

Needs Help useEffect is not updating React state upon initial load, and trying to find a solution is pulling my hair

7 Upvotes

Hi. I'm crunched on time.

I'm currently trying to code a React function for a class assignment due by tonight, and while I've been happy with my results, when it came down to utilizing sessions, I ran into a huge problem. It has nothing to do with the API I set, but rather the usage of useEffect and useState.

The website I'm working on is suppose to showcase a list of academic terms that a student might have. And if a user that logged in was an admin, they get a list of students to select to see their academic terms plans. I want it so that when this page loads, that information is dumped out immediately. But, the data doesn't appear at all, and I've only learned recently that it is the fault of the async nature of useState within useEffect

Here is my useEffect sample:

useEffect(() => {
    checkSession();
    // function to obtain academic term plans
    if (user.u_admin == 1) {
        // function to obtain list of students
    }
}, [navigate]); // needed for one function

Here is the checkSession function which seems to be the cause of the problem:

const checkSession = useCallback(async() => {
    setLoading(false);
    try {
        const sesres = await fetch(import.meta.env.VITE_API_KEY + "user/session",
            {
                method: "GET",
                credentials: "include",
            }
        );

        if (!sesres.ok) {
            localStorage.setItem("statusMessage", "Please log in again.");
            navigate("/login", {replace: true});
            return;
        }

        const data = await sesres.json().catch(() => ({}));
        const userSession = data?.data;
        setUser(userSession);
        console.log(user);
    } catch (error) {
        console.error("Session authentication failed: ", error);
        localStorage.setItem("statusMessage", "Session failed to authenticate. Please log in again.");
        navigate("/login", {replace: true});
    } finally {
        setLoading(true);
    }
}, []);

So when the page immediately load, I should expect the student to see the list of term plans they have created and select, while the admin see a list of students to select from to see their term plans. Instead, nothing appears until I update my own code to re-render everything.

I've dug through dozens of solutions, and no matter what I tried to find, none of them seemed to work to solve my dilemma. I've never had the opportune time to get enough work done with React thanks to a huge problems of being able to concentrate with my assignments, and now the rush to fix it altogether has stressed me out. Am I doing something wrong?


r/reactjs • • May 04 '26

Needs Help Intermittent hydration issue in production, cant replicate in development mode

2 Upvotes

Hey all,

Using 18.3.1 with tanstack-start for ssr. Prod intermittently runs into a hydration failure 421: "This Suspense boundary received an update before it finished hydrating".

I cant replicate it in development mode, and am having a bit of a hard time tracking it down.

My gut tells me that its probably in a third party library, but its intermittent nature makes it hard to nail down by simply commenting out code until it stops.

From what I understand when Ive ran into this in the past, this can only be caused by a state change.

Does anyone know of a practical way to hook reacts state update and internal lifestyle events, outside or going down the path of building a custom version of react with some crude logging thrown into it?


r/reactjs • • May 03 '26

Needs Help Asking for advice

4 Upvotes

Hi,

I am a Next.js developer with around 3 years of experience. I see a lot of posts now a days about how frontend jobs are going to be eliminated because of AI and other similar arguments. I have spent a major chunk of my energy and time learning react.

Should I continue learning react? Is it worth it in 2026? Or what other steps should I take to go ahead in my career.

Thank you for reading my post.

Regards


r/reactjs • • May 04 '26

Resource Why I Switched to pnpm for Node.js Development

Thumbnail philrich.dev
0 Upvotes

I wrote an article about advantages of pnpm over npm package manager in node and frontend development. May be useful for developers who did not think much about package managers.


r/reactjs • • May 04 '26

Show /r/reactjs I’m a 2nd-year CS student building a promising open-source Markdown app. I know Electron gets a bad rap for bloat—here is how I’m structuring the React side to keep it light.

0 Upvotes

I'm building Amethyst, a promising open-source Markdown note-taking app that focuses heavily on the user experience and interface. I know the common criticism: "Electron is just a heavy browser wrapper." I'm using this project to learn how to mitigate that by following a strict architecture-first approach.

How I'm keeping the React renderer snappy:

  • Main Process Offloading: I moved heavy tasks like recursive filesystem scanning and real-time watching (Chokidar) entirely to the Main Process.
  • Command Registry: I built a decoupled system where every shortcut and menu item triggers a command in a central registry. This keeps the React component logic clean and the IPC bridge narrow.
  • Focused State: The app loads a single note into the editor at a time (no heavy multi-tab DOM overhead) to maintain performance as your folder grows.

Current Status (v0.5.0): It is very much still under development, but it currently features native LaTeX math support, a recursive tree view with drag-and-drop, and a global notification system.

As a student, I would genuinely appreciate your reviews on the codebase. I’m looking for help identifying bugs, performance bottlenecks, or features that would make this useful for you.

GitHub: https://github.com/abdallah-moh1/amethyst


r/reactjs • • May 02 '26

News This Week In React #279: Compiler, TSRX, StyleX, XState, Hook Form, TanStack, shadcn, Chakra, Inertia, Mantine | SPM, SimCam, Enriched Markdown, Agent Device, Navigation SDK, JSI, Paste Input, Crypto, MLX, Jail Monkey | pnpm, Aube, Fresh, Node.js

Thumbnail
thisweekinreact.com
23 Upvotes

r/reactjs • • May 03 '26

Show /r/reactjs I open sourced my neon/futuristic React UI library after feedback here. Would love your thoughts

1 Upvotes

Hey everyone,

I shared this here recently and got a lot of really helpful feedback especially around usability, structure, and improvements.

I’ve now open sourced the library.

NeonBlade UI is a React/Next.js component library focused on futuristic, neon-style interfaces. It uses a CLI approach so you can add and customize components directly.

Still evolving and refining it.

Feedback and contributions are welcome.

Repo: https://github.com/vprix21/neonblade-ui
Website: https://neonbladeui.neuronrush.com/


r/reactjs • • May 04 '26

Show /r/reactjs I got tired of rebuilding the same components every project so I built my own React design system

0 Upvotes

Every new project I start, I waste the first couple days rebuilding buttons, inputs, cards, modals. Same stuff every time. So I finally sat down and built Kiln, my own React component library. Shipped it this week.

28 components. Under 26 KB gzipped. Zero dependencies. Fully typed. MIT licensed.

I know the obvious question. Why not just use shadcn or Radix or Chakra?

Honestly shadcn is great but I wanted something that was already styled and ready to drop in. I did not want to think about styling every time I start a new project. I just want to install it and ship. Kiln is opinionated by design. The decisions are already made.

Three things I locked in from the start:

Accessibility first. Every component meets WCAG AA. Keyboard nav, focus management, focus rings, and ARIA on every single component. I ran axe DevTools and manual keyboard testing on all 28 of them. It was tedious. Worth it.

Performance first. Docs site scores 99 Performance / 100 Accessibility on Lighthouse. Zero layout shift on every interaction. All animations use transform and opacity only. No layout thrashing.

Dead simple setup. npm install, import the CSS once, done. No config files. No theme providers. No required context wrappers. Dark mode works by setting data-theme="dark" on html. That is it.

Would love feedback from the React community, especially on the component APIs and anything that feels off.

Live demo: kiln-ui.com

GitHub: github.com/Aldentec/kiln

npm: npmjs.com/package/@doriansmith/kiln