Next.js Discord

Discord Forum

Build once, deploy anywhere

Unanswered
Himalayan posted this in #help-forum
Open in Discord
HimalayanOP
Is there an established pattern for creating a build once, deploy anywhere bundle for a Next.js app? My usecase needs to supply the client app with a server API URL (obvs not secret), and a bunch of NextAuth secrets.

The research I've done suggests that I can't do this outside of the build, as the env vars get written into the bundle. I need to be able to supply them when the app is started on the server.

Does anyone know if this is possible? 🙂

1 Reply

HimalayanOP
For anyone struggling with this in future, I've found this which has proved to be the answer: https://github.com/expatfile/next-runtime-env