It has something to do with the
npm i current-git-branch --save-dev
const currentGitBranchName = require("current-git-branch");
It works for both client side and server side, because it happens at build time and the environment variable has been injected into the code.
Hope it helps.
Thanks for reading!
Follow me (albertgao) on twitter, if you want to hear more about my interesting ideas.