Here's the thing - the other frameworks I work in don't encourage me to require secrets on the client-side, so you're exactly right. The client-server split that is enforced by Next.js's App Router paradigm is not an abstraction, but more like a rift through the center of the web development universe. I don't want to send env variables to the client, but sometimes they have to be shipped with the bundle to cross this great chasm. It's like that scene in Interstellar when Coop and his team gets sucked into the black hole. Him returning to see Murph is like a client issuing a fetch request to the server, as far as Next.js is concerned
And I already know what the answer is, it's "anticipate every possible future scenario that your web program might encounter, and design your server/client structure perfectly the first time! What's so hard about that?"
This experience with Next.js has made me quit the Javascript/Typescript communities of web frameworks entirely. Burned by Gatsby and GraphQL once, shame on them. Burned by Next.js though...
it’s so much easier to fix this in NextJS compared to other stacks though, I have done it a few times where I end up w secret using code in the client while prototyping but it’s just a single line of text at the top of a file to make it server and keep the existing async call sites. NextJS is not great at some stuff but moving code from client to server it’s like second to none
And I already know what the answer is, it's "anticipate every possible future scenario that your web program might encounter, and design your server/client structure perfectly the first time! What's so hard about that?"
This experience with Next.js has made me quit the Javascript/Typescript communities of web frameworks entirely. Burned by Gatsby and GraphQL once, shame on them. Burned by Next.js though...