Skip to content

Getting started with Hook Crafter

Hook Crafter is a Vite and TypeScript template for building your React hook library.

Create the project

To create a Hook Crafter project, run:

sh
npx create-hook-crafter
sh
npx create-hook-crafter
sh
pnpm dlx create-hook-crafter

Then follow the prompt.

Install the dependencies

Install the dependencies with npm, yarn, or pnpm.

sh
npm install
sh
yarn
sh
pnpm install

Create your hooks

Create all your hooks inside the src/hooks directory and export them in the index.ts file.

typescript
import { useState } from "react";

export const useCountUp = (increase: number) => {
  const [count, setCount] = useState(0);

  const increment = () => setCount(count + increase);
  return { count, increment };
};
typescript
export * from "./useCountUp";

Released under the MIT License.