With NextJS, it’s possible to create a build ID, according to the docs : https://nextjs.org/docs/app/api-reference/next-config-js/generateBuildId
It’s also possible to get it according to the last git version : https://www.npmjs.com/package/next-build-id
But the question is : how do I read this build ID? I’d like to display it inside the window console.
2
Answers
I have not tested it, but I think you can try the old (I guess it’s deprecated now, but it still should work) way of passing
env
vars through theenv
key in the config, like that:And it will be available later as
process.env.BUILD_ID_ENV
To use it in the client side component potentially you would have to name it as
NEXT_PUBLIC_BUILD_ID_ENV
, not sure about it.this works in server component because that package uses
fs
proof of work: