Add Husky to NextJS app

Add Husky to NextJS app

1. Installation

terminal

2. Initialize husky

The command creates a .husky folder with all the necessary client hooks present in the _ folder. This is how it looks like.

Screenshot_2024_06_12_at_16_39_54_cf9678fa2c copy.png-img
terminal

Additionally, it adds a prepare script to package.json.

This is how it looks like.

Screenshot 2024-06-12 at 16.41.07.png-img

Add 2 extra scripts in package.json

package.json

Add a precommit hook.

In ./husky/pre-commit file add:

./husky/pre-commit

Add a pre-push hook.

./huskey/pre-push

Test if it works.

Now try to add a commit.

terminal