Next.js Discord

Discord Forum

Changing next.config.js variables after build.

Unanswered
Boykin Spaniel posted this in #help-forum
Open in Discord
Boykin SpanielOP
I am building a NextJS application for the management field. I want to be able to change environment variables after running npm run build without having to run the build command again every time I change the environment variable value. Anyone have any ideas?

6 Replies

Cant be changing environment variables after build.

As for the solution:
One solution i can think of is using a KV store.
I dont know a better solution, maybe wait for some other's opinion too
I'm not sure what exactly you are storing in those specific environment variables but something like this can be used too:
https://vercel.com/docs/storage/edge-config
Spectacled bear
Could you share the usecase? What kinda values? Are they secret keys or something else
@Spectacled bear Could you share the usecase? What kinda values? Are they secret keys or something else
Boykin SpanielOP
I have several domain urls that need to be changed depending on the environment I need to use. So I need to change the values of environment variables continuously. However, I don't want to rebuild the app continuously