You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, when using the @t3-oss/env-nextjs package for environment variable validation and extraction, we are required to use lengthy environment variable names prefixed with NEXT_PUBLIC_ for client-side accessible variables. This often leads to overly verbose code, especially when accessing multiple environment variables.
I propose adding an option to customize the prefix for client-side environment variables within the createEnv function. This enhancement would allow developers to define shorter or different prefixes as per their project's conventions, improving code readability and flexibility.
Introducing a customizable prefix option would not affect the existing functionality for those who prefer to use the default setting. It simply provides an additional configuration option for those looking to tailor their environment variable setup more closely to their project's needs.
The text was updated successfully, but these errors were encountered:
derodero24
changed the title
Allow Customize ] Environment Variable Keys in @t3-oss/env-nextjs
Allow customize client prefix in @t3-oss/env-nextjsMay 8, 2024
derodero24
changed the title
Allow customize client prefix in @t3-oss/env-nextjs
Support Custom Prefixes for Client Environment Variables in @t3-oss/env-nextjsMay 8, 2024
the prefix isn't something you control though - it's implemented in the framework to handle this.
if we were to support this it would
a) we'd have to remap NEXT_PUBLIC_FOO to NP_FOO in the lib - you'd still need to have NEXT_PUBLIC_FOO= in your .env.
a) be confusing to new devs who knows about nextjs that a variable not named NEXT_PUBLIC_X is shipped to the client
Overall I think it would be a bad call going away from the standard here
Currently, when using the
@t3-oss/env-nextjs
package for environment variable validation and extraction, we are required to use lengthy environment variable names prefixed withNEXT_PUBLIC_
for client-side accessible variables. This often leads to overly verbose code, especially when accessing multiple environment variables.I propose adding an option to customize the prefix for client-side environment variables within the
createEnv
function. This enhancement would allow developers to define shorter or different prefixes as per their project's conventions, improving code readability and flexibility.Example
Introducing a customizable prefix option would not affect the existing functionality for those who prefer to use the default setting. It simply provides an additional configuration option for those looking to tailor their environment variable setup more closely to their project's needs.
The text was updated successfully, but these errors were encountered: