79788577

Date: 2025-10-12 13:26:09
Score: 1
Natty:
Report link

probably you’ve solved this, but i faced with your article and decided to share my workaround about the way i’ve solved it also

We initially chose the original next-runtime-env library because we wanted a Docker image that worked for multiple environments (build once, deploy many). However, using the library caused various issues with navigation. First, I encountered a bug when navigating using router.push from the custom not-found page. Then, after integrating ISR to improve performance and splitting different app layers with separate layouts, jumping between them also wiped out my global env variables.

I had two options to solve this:

I hesitated with the first option because in next-runtime-env's server environment, when you use the env() getter to get a variable from process.env[key], it calls unstable_noStore() (aka connection()), which enables dynamic rendering. I wanted to reduce unnecessary dynamic rendering. This caused issues when I moved a room from SSR to ISR. Where dynamic rendering was needed, I decided to fetch data client-side and show skeleton loaders 💅.

A few points about the final implementation for those interested:

Now that I no longer depend on next-runtime-env, I can access runtime env in server components without enabling dynamic rendering. This opens the door for further performance improvements, such as migrating individual app pages from SSR to SSG/ISR.

Reasons:
  • Contains signature (1):
  • Long answer (-1):
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: Unsleeping