Create and Visualize a Pin Input State Machine with TypeScript and Zag.js

InstructorSegun Adebayo

Share this video with your friends

Send Tweet

We've mapped out what a Pin input state machine should look like so now it's time to start implementing that in code.

We'll be using Zag.js to model the machine for us. Zag.js works well with TypeScript so the first thing to do is create types for the machine context and state. Then we'll stub out the states, transitions, and actions for the machine.

While we aren't implementing the actions in this lesson you'll quickly see how a state machine makes complex interactions easier to understand by the events that occur and the actions that are triggered by those events.

Lastly, we'll paste our machine in the stately machine visualizer and you'll see a visual representation of the machine that was created.