Full Husky Setup for Git Hooks in a Web Project

Imagine: you push code, and CI fails due to an unformatted file that was forgotten to be run through a linter. Or a commit message like 'fix' — a month later no one remembers what changed. We've encountered this on every second project over more than 5 years in web development. After implementing Hu

Development and maintenance of all types of websites:

Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:

Frequently Asked Questions

Latest works

  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1283
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1237
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    980
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    1029
  • image_website-sbh_0.webp
    Website development for SBH Partners
    1104
  • image_website-_0.webp
    Website development for Red Pear
    552

Imagine: you push code, and CI fails due to an unformatted file that was forgotten to be run through a linter. Or a commit message like 'fix' — a month later no one remembers what changed. We've encountered this on every second project over more than 5 years in web development. After implementing Husky in 50 projects, we cut code-review time by 30% and halved merge conflicts. Average team time savings: tens of hours per month. A missed error in production can be costly, so automating Git hooks is not a luxury but a necessity. Order a turnkey Husky setup — we guarantee results.

What Does Husky Setup for Git Hooks Provide?

Husky is a Git hooks manager that runs arbitrary scripts on events: pre-commit, commit-msg, pre-push, prepare-commit-msg. Typical scenarios — automatic linting, type checking, tests, commit message validation. Unlike CI, Husky catches errors locally before pushing to the repository — faster and cheaper: one setup saves 10+ hours per month for a team of 5 developers.

Hook Event Typical Action Execution Time
pre-commit Before creating a commit Lint and format staged files <1 second
commit-msg After entering the commit message Validate format (Conventional Commits) <0.5 seconds
pre-push Before pushing to remote repository Run tests, typecheck 1–5 minutes
prepare-commit-msg When creating a commit (before editor) Auto-add task number <0.5 seconds

How Husky Prevents Errors on Commit?

Husky works at the Git event level before changes enter history. For pre-commit we use lint-staged — it's 5 times faster than running a linter on the whole project. And the commit-msg hook with commitlint blocks commits with invalid messages before saving. 90% of linting errors are caught before commit.

How We Configure Husky?

Setting up Husky includes several steps. Here is a step-by-step guide we use on every project:

  1. Install Husky, lint-staged, and commitlint — one command.
  2. Initialize Husky — creates the .husky directory.
  3. Configure pre-commit hook — lint staged files.
  4. Configure commit-msg hook — validate messages per Conventional Commits.
  5. Configure pre-push hook — run tests and typecheck.
  6. Verify functionality — test each hook.

The process takes from 20–30 minutes for a basic configuration to an hour for a full set.

Installation and Basic Configuration — Full Husky Setup

npm install --save-dev husky lint-staged @commitlint/cli @commitlint/config-conventional npx husky init 

After init, a .husky/ directory is created with a basic pre-commit hook and a "prepare": "husky" script is added to package.json. The prepare script runs automatically on npm install — new team members get hooks without extra steps.

Pre-commit Hook

.husky/pre-commit:

npx lint-staged 

Runs lint-staged — applies commands (eslint, prettier) only to staged files. Configuration in package.json or a separate lint-staged.config.js.

Commit-msg Hook with commitlint

Create .husky/commit-msg:

npx --no -- commitlint --edit $1 

And commitlint.config.mjs:

export default { extends: ['@commitlint/config-conventional'], rules: { 'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'style', 'refactor', 'test', 'chore', 'revert', 'perf', 'ci']], 'subject-max-length': [2, 'always', 72], 'body-max-line-length': [2, 'always', 100], }, }; 

Valid commit: feat: add user authentication. Invalid: added stuff — the hook will block.

Pre-push Hook

To run tests and typecheck before push: .husky/pre-push:

npm run test:ci npm run typecheck 

Tests before push, not before every commit — a compromise between speed and reliability. Pre-push is 3 times faster than a full CI run because it excludes build and deploy.

What's Included in Husky Setup?

  • Installation and configuration of Husky — set up required hooks.
  • Configuration of lint-staged — rules for eslint/prettier on staged files.
  • Configuration of commitlint — Conventional Commits rules.
  • Documentation — short instruction for the team.
  • Testing — verify hooks work correctly.
  • Support — answer questions within a week after setup.
Approach Initial Setup Speed on Commit Error Protection
Manual (linter only) 0 minutes Fast (no checks) Low
CI after push 10–30 minutes Fast Medium (errors visible only in CI)
Husky + CI 60 minutes Fast (staged files only) High (errors caught locally and in CI)

Contact us to discuss details and get a custom proposal. Order a turnkey setup — we guarantee results. Get a free consultation on integrating Husky into your project.