🔧
Build Tool10M+/wkMIT

husky

Husky is a tool that makes Git hooks easy to use in JavaScript projects, enabling teams to enforce code quality checks before commits and pushes are accepted. G

Installation

npm
npm install -D husky
yarn
yarn add -D husky
pnpm
pnpm add -D husky

Import

ESM
// Used as Git hooks, not imported

Quick Example

usage
// Setup: npx husky init

// .husky/pre-commit
npx lint-staged

// .husky/commit-msg
npx commitlint --edit $1

About husky

Husky is a tool that makes Git hooks easy to use in JavaScript projects, enabling teams to enforce code quality checks before commits and pushes are accepted. Git hooks are scripts that run automatically at specific points in the Git workflow — pre-commit, commit-msg, pre-push, and others — but configuring them manually requires editing files in the .git/hooks directory which is not tracked by version control. Husky solves this by storing hook scripts in the project's .husky directory, which is committed to the repository, ensuring all team members run the same hooks. Common uses include running linters and formatters on staged files before commit (using lint-staged), validating commit messages against conventional commit format (using commitlint), running type checks before push, and preventing commits to protected branches. Husky v9 uses a simpler shell-based approach where each hook is a plain shell script. The tool requires a one-time setup (npx husky init) that configures the Git hooks path to use the .husky directory. Husky is an essential component of professional JavaScript development workflows, catching quality issues before they enter the repository.

Quick Facts

Packagehusky
CategoryBuild Tool
Weekly Downloads10M+
LicenseMIT
Installnpm install -D husky

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.