How to automatically add commit hash / build version to frontend?
Unanswered
Chinese Egret posted this in #help-forum
Chinese EgretOP
Hi, I am trying to add an auto-generated commit has or build version on every commit, that will show up somewhere in the app. Anyone know how?
10 Replies
const { version } = require('./package.json');
const nextConfig = {
reactStrictMode: true,
swcMinify: false,
i18n,
env: {
NEXT_PUBLIC_VERSION: version,
},
reactStrictMode: true,
swcMinify: false,
i18n,
env: {
NEXT_PUBLIC_VERSION: version,
},
This is one way if you want to bake in a version at build time .
Also if you deploy to vercel
Then the commit hash and other info as available as env variables
Check their docs to see a list of what’s available
Chinese EgretOP
Thanks @linesofcode
I was trying to find the Vercel env vars
Ah here it is