Rehooks

Guide

Learn how to install and interact with Rehooks CLI

Installation

To use the CLI, you can execute it directly with the latest version:

Terminal
npx rehooks-cli@latest

Guide

At first, you must initialize the Rehooks configuration. To do this, run the following command:

Terminal
npx rehooks-cli init

If your project includes a src directory, you must select yes whenever you use init. It will create a rehooks.json in the root of your project. This file contains the directory where the hooks will be imported.

If you want to use a custom path for the hooks directory, you can pass it as an argument to the init command.

Rehooks CLI requires React version 18 or higher. If your project uses a lower version, you may encounter compatibility issues. Also your project must include package.json file.

Now It's time to add hooks into your project. To achieve this you must use the add command.

Terminal
npx rehooks-cli add

This command will ask you to select the hooks you want to add. You can select multiple hooks by pressing the space key.

Usage

Terminal
npx rehooks-cli [options] [command]

Arguments are optional. You may want to leave args empty, so by running npx rehooks-cli add you'll access to the list of hooks.

Terminal
npx rehooks-cli add useFocus useFetch useWindowSize

Options

These are the options available in the CLI.

OptionDescription
-v, --versionDisplays the version number
-h, --helpDisplays help for command

Commands

CommandDescription
init [options] [path]Initialize the Rehooks configuration
add [options] [hooks]Add custom hooks to your project
help [command]Displays help for a specific command

Init

OptionDescription
-f, --forceForce overwrite existing configuration without prompt
-c, --config <path>Specify a custom path for rehooks.json
-h, --helpDisplays help for command

Add

OptionDescription
-f, --forceForce overwrite existing hook files without prompt
-h, --helpDisplays help for command

On this page