Set public (browser) env vars without NEXT_PUBLIC prefix for other libraries #21850
nicholaschiang
started this conversation in
Ideas
Replies: 1 comment
-
@nicholaschiang You can set this mapping using the const { DRAGGABLE_DEBUG } = process.env;
module.exports = {
env : {
DRAGGABLE_DEBUG
}
} Your The If you want to change it at runtime and not build time: https://nextjs.org/docs/api-reference/next.config.js/runtime-configuration. Hope that helps! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Describe the feature you'd like to request
I need to be able to set public (exposed in the browser) environment variables without the
NEXT_PUBLIC
prefix in order to set environment variables for other libraries.For example, when debugging with
react-draggable
I want to be able to set thatprocess.env.DRAGGABLE_DEBUG
environment variable in the browser to see the library's logs:Describe the solution you'd like
We should be able to override the default
NEXT_PUBLIC
public environment variable prefix innext.config.js
like so:Or something similar to the above. Next.js should still by default expose variables with
NEXT_PUBLIC
but we should also be able to expose variables without needingNEXT_PUBLIC
.Describe alternatives you've considered
I could OFC compile the
react-draggable
library myself from source (and replace theprocess.env.DRAGGABLE_DEBUG
variable during compilation) but that'd be far from ideal.Beta Was this translation helpful? Give feedback.
All reactions