Runtime Config
Unfortunately, this feature does not work on Vercel deployments since we are not able to write to the file system which is required for the runtime config file.
Essencium provides the ability to pass a runtime config to your instance beside a build config. This feature shines when having i.e. multiple
enironments like development, staging, production and you want to have different configurations for each environment without the need to rebuild
the application.
How it works
Essencium utilises the instrumentation.ts (opens in a new tab) function that is invoked when starting the Next.js server. This function is responsible for
population the runtimeConfig.js file based on the given environment variables inside the .env file. It is then read by the application at different places. You can consider it as glue between the .env file and the application.
Adding a new environment variable
- Adding the new environment variable to the
.envfile - Adding the new environment variable to the
instrumentation.tsfile underREPLACEMENTSobject and the corresponding scope (requiredoroptional) - Adding the new environment variable to the
runtimeConfig.tsfile under the corresponding scope (requiredoroptional)
When adding a new environment variable inside the required scope, the
application will fail to start if the variable is not provided via the .env
file.
Do not modifiy the values inside the runtimeConfig.js file directly. The
values are populated by the instrumentation.ts file automatically.