-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add documentation about environment variables #2452
Conversation
Since the pages router counterpart is called ScaffoldedEnvVars it's inconsistent if this one's called ClientContextEnvVariables. They should either both be …EnvVars or both be …EnvVariables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a great addition to the docs. I'm sorry for pulling the rug out on this otherwise (almost) mergable PR but I made some changes in #2447 before merging it that are now causing merge conflicts (and perhaps worse) here.
Basically, the types for environment variables should be consistent across the pages and app router. I took one small step in that direction in ba86abc but maybe this is a good PR to make it fully consistent?
Oh nice, glad you aligned these already. I think it will make adding and removing these things even easier as you'll be able to update one central type and then treat the resulting type errors as a to-do list for completely integrating the new env var into both the app router and the page router. Looks like only teeny tiny changes ahead here so with any luck won't take long if I get a few spare minutes here and there. |
Right then, the merge commit is 0e1a520. At first I was going to sit and daydream about a nice general name for a shared type. Then it occurred to me that maybe this isn't something that needs to be so meticulously neutral. If the goal state is to one day have everything be on the app router then maybe just focusing on the app router a little bit in these kinds of details is best. So I kept |
Should probably add something about useEnv to this right? Adding a new env var is covered nicely here but your other most likely question as someone who maybe knows Next.js but is new to Zetkin is how to read them. |
lol I just found another Do we want to use that instead of this new ClientContextEnvVars? The fact that it makes everything optional seems to be really convenient for writing stuff like unit tests where I see lots of places defining only the ones that matter for the individual test. |
Yeah that sounds like a good idea! But unless I'm thinking about this the wrong way, it will mean that you lose the benefit of being able to change the type and get the type errors as a Todo. I guess you can change the type without making the new var optional, handle the errors, and then make it optional. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I think this is ready to merge! 💯
Let me just say again, lovely to have you back on the roster! 🙌
Talked about documenting this in #2447. Here's a first draft!