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 install -D husky
yarn add -D husky
pnpm add -D husky
Import
// Used as Git hooks, not imported
Quick Example
// 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
| Package | husky |
| Category | Build Tool |
| Weekly Downloads | 10M+ |
| License | MIT |
| Install | npm install -D husky |
Related Packages
lint-staged is a tool that runs linters and formatters on only the files that are staged in Git, mak…
Prettier is an opinionated code formatter that enforces a consistent code style across your entire c…
ESLint is the standard linting tool for JavaScript and TypeScript that analyzes your code to find an…
Changesets is a tool for managing versioning and changelogs in multi-package repositories, focusing …
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.