Skip to content
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

feat: custom public env prefix #67791

Draft
wants to merge 4 commits into
base: canary
Choose a base branch
from

Conversation

Netail
Copy link
Contributor

@Netail Netail commented Jul 15, 2024

Note

This is a proposal, wondering what you guys think about this idea

What?

Set custom public env variable prefix

Why?

Sometimes the prefix NEXT_PUBLIC_ can be a little confusing, so a way to set a custom prefix could help improving DX?

Idea from #66458, also kind of related to #56093

How?

Experimental option for a custom prefix

@ijjk
Copy link
Member

ijjk commented Jul 15, 2024

Allow CI Workflow Run

  • approve CI run for commit: 167a14e

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

@Netail Netail closed this Jul 15, 2024
@Netail Netail force-pushed the feat/custom-public-env-prefix branch from 0c7ecd5 to 08da98d Compare July 15, 2024 22:30
@Netail Netail reopened this Jul 15, 2024
@Netail Netail force-pushed the feat/custom-public-env-prefix branch from fc408a3 to 80a31a4 Compare July 15, 2024 22:37
@kachkaev
Copy link
Contributor

There may be npm libraries who expect public vars prefixed as NEXT_PUBLIC_. If an app is configured with different prefix, these libraries won't work correctly. Even though NEXT_PUBLIC_ is somewhat verbose, it’s not confusing because it’s the same for everyone. Customisation can bring more confusion and complexity IMHO.

@Netail
Copy link
Contributor Author

Netail commented Jul 16, 2024

There may be npm libraries who expect public vars prefixed as NEXT_PUBLIC_. If an app is configured with different prefix, these libraries won't work correctly. Even though NEXT_PUBLIC_ is somewhat verbose, it’s not confusing because it’s the same for everyone. Customisation can bring more confusion and complexity IMHO.

What about allowing multiple prefixes? With NEXT_PUBLIC_ always being included. This way libraries with NEXT_PUBLIC_ are still working + can everyone configure their own prefix (even libraries)

@igo
Copy link

igo commented Jul 16, 2024

Confusion begins when you ship your app built on top of Next.js, and users have no idea what NEXT_PUBLIC_ is. For that reason, there should be a way to rename it to something like MYAPP_PUBLIC_. Libraries that rely on hardcoded NEXT_PUBLIC_ will have to be updated. Indeed, this can be a breaking change, but that should not stop us from merging it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants