← Back
git hash node

Latest commit on node env

Access the latest commit hash (server side):

import { execSync } from "child_process";

function setGitCommitToEnv() {
const gitCommit = execSync("git rev-parse HEAD").toString().trim();
process.env.GIT_COMMIT = gitCommit;
}