
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
use-wizard
Advanced tools
A dead-easy-to-use light-weight react hook to handle multi-paths wizards (and simple wizards too) and navigate into them.

Below you will find 3 examples. Each of them describe a different way of declaring your wizard.
npm i use-wizard
const useWizard = require('use-wizard');
or
import {useWizard} from "use-wizard";
// For a linear wizard with numbers
const [step, wizard] = useWizard();
or
// For a linear wizard with strings
const [step, wizard] = useWizard(['splash', 'name', 'email', 'terms', 'validation']);
or
// For a nested wizard
const [step, wizard] = useWizard(["A", "B", {
"1": ["C", "D", "E"],
"2": ["F", "G"]
}, "H"]);
There you go, that's all.
Now you can just use a switch to display content according to steps and use methods stored in wizard to navigate.
| linear wizard (numbers) | linear wizard (strings) | nested wizard | |
| history | ✔ | ✔ | ✔ |
| nextStep | ✔ | ✔ | ✔ |
| previousStep | ✔ | ✔ | ✔ |
| nPreviousSteps | ✔ | ✔ | ✔ |
| nForwardSteps | ✔ | ✔ | ✔ |
| forwardStep | ✔ | ✔ | ✔ |
| initialize | ✔ | ✔ | ✔ |
| goToStep | ✔ | ✔ | ✔ |
| jumpSteps | ✔ | ❌ | ❌ |
| stepIndex | ❌ | ✔ | ❌ |
| wizardLength | ❌ | ✔ | ❌ |
In this ultra-basic lizard (linear-wizard) scenario, each step is a number. Look at figure 1.1 bellow to see what we will achieve.
figure 1.1
const [step, wizard] = useWizard();
Instead of numbers, we will now use names (strings) for our steps.
We will first study a lizard scenario. We will then study two non-linear wizards.
This scenario is very close to the one above, but each step of the wizard is now a string. Look at figure 2.1 bellow to see what we will achieve.
figure 2.1
Declare your wizard with an array of strings like so:
const [step, wizard] = useWizard(["A", "B", "C"]);
useWizard allows you to create non-linear paths in a simple declarative way. Look at figure 2.2 bellow to see what we will achieve.
figure 3.1
All we have to do is to declare the wizard like above, but we will use an object instead of a string when we have different possible paths.
The example of the figure 3.1 would be written like this:
const path = ["A", "B", {
"1": ["C", "D", "E"],
"2": ["F", "G"]
}, "H"];
const [step, wizard] = useWizard(path);
Again, most methods described in the first example works out of the box (see table bellow).
This example only takes complexity a step ahead to show you what you can achieve. I will just give you the figure 2.3 and the declarative wizard that goes with it.
figure 4.1
The example of the figure 4.1 would be written like this:
const path = ["A", "B", {
"1": ["C", "D", "E"],
"2": ["F", {
"1": ["G", "H"],
"2": ["I", "J", "K"]
}, "L"]
}, "M"];
const [step, wizard] = useWizard(path);
The first step would be again the step "A", and you can use all methods from the wizard object like above.
As deep as you need it to be, you can nest parallel paths as much as you need to
This hook relies on two stacks stored as states. One is the history-stack, used to store the actual path the user took. The other one is the popped-history-stack, so the user can go forward when he went backward (see examples).
This hook heavily relies on recursion to identify steps in a nested pattern.
useWizard "only" helps you to handle multi-paths wizards. If you need to handle data (let's say you are using big nested forms), I invite you to check use-formidable.
Do not hesitate to ask for features / PR / or join
FAQs
A dead-easy-to-use light-weight react hook to handle multi-paths wizards (and simple wizards too) and navigate into them.
We found that use-wizard demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.