Skip to content

Instantly share code, notes, and snippets.

@coltenkrauter
Last active September 8, 2025 18:51
Show Gist options
  • Save coltenkrauter/c5681cee1d639007ebfee2b4efd0b1af to your computer and use it in GitHub Desktop.
Save coltenkrauter/c5681cee1d639007ebfee2b4efd0b1af to your computer and use it in GitHub Desktop.
Display app version, commit hash, and build timestamp in your Next.js app footer.

Next.js + Vercel Build Info

Inject and display build metadata in your Next.js app deployed on Vercel:

  • App version from package.json
  • Commit SHA from Vercel git env vars
  • Build time generated once per next build

How it works

  1. Read package.json for the app version.
  2. Capture current ISO timestamp at build.
  3. Use Vercel-provided env vars for repo + commit details.
  4. Expose everything through NEXT_PUBLIC_* so it’s available in SSR and client code.
  5. Render in a shared component (e.g. footer).

Vercel env vars used

  • VERCEL_GIT_REPO_OWNER
  • VERCEL_GIT_REPO_SLUG
  • VERCEL_GIT_COMMIT_SHA
import type { NextConfig } from 'next'
const version = require('./package.json').version
const buildTime = new Date().toISOString()
const repoUrl = `https://github.com/${process.env.VERCEL_GIT_REPO_OWNER}/${process.env.VERCEL_GIT_REPO_SLUG}`
const commitSha = process.env.VERCEL_GIT_COMMIT_SHA || ''
const nextConfig: NextConfig = {
reactStrictMode: true,
env: {
NEXT_PUBLIC_APP_VERSION: version,
NEXT_PUBLIC_BUILD_TIME: buildTime,
NEXT_PUBLIC_COMMIT_SHA: commitSha,
NEXT_PUBLIC_REPO_URL: repoUrl,
},
}
export default nextConfig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment