Next.js 14 introduced the feature to seed data
Note: As of this writing, it’s an experimental feature, but it has worked for me when deploying on Vercel.
- Create (or edit) next.config.(mjs/js) file.
- Add the
instrumentationHook: true
in the config.
- Add a new file instrumentation.(ts/js)
in the applications src
folder (or whatever you have chosen)
- After some trial and error, this is what has worked for me.
- My initializeFeatureFlags
function is a regular server side function that calls my database.