A hook for managing step-based navigation logic.

Installation

pnpm dlx shadcn@latest add https://mhl5.vercel.app/r/useStepper.json

Usage

import { useStepper } from "@/hooks/useStepper";

// With number of steps
const { currentStep, isFirstStep, isLastStep, goTo, next, back } = useStepper(
  3,
  { initialStep: 0, loop: false },
);

// With step components
const steps = [<Step1 />, <Step2 />, <Step3 />];
const { currentStep, step, next, back } = useStepper(steps);