Power-User Systems

Pathfinder

A pathfinding visualizer on a grid. Watch A*, Dijkstra, breadth-first or greedy search spread through a maze, then draw the path it found. Drag to draw or erase walls, or drag the start and the goal to move them. The path updates while you draw. Left alone, it builds a new maze, solves it and starts over.

Install

# Pathfinder needs no npm packages

Then copy 3 files into your project:

  • components/registry/pathfinder/pathfinder.tsx
  • components/registry/pathfinder/pathfinder-engine.ts
  • hooks/use-animation-loop.ts

Props

PropTypeDefaultDescription
algorithm"astar" | "dijkstra" | "bfs" | "greedy""astar"Which search runs.
maze"backtracker" | "prim" | "scatter""backtracker"How new walls are laid out.
diagonalbooleanfalseAllow diagonal steps. A diagonal can't cut across a wall's corner.
speednumber1How fast the search spreads.
cellSizenumber18Size of one grid cell.
autoplaybooleantrueBuild a maze, solve it and start over while you are not editing.
searchColorstring (hex)"#a855f7"Cells the search has explored.
pathColorstring (hex)"#f0abfc"The path it found.
boardColorstring (hex)"#0d0b12"The grid. Walls are drawn a shade off it.

What It Demonstrates

Loop
An animation that repeats, a set number of times or infinitely.
Idle animation
Subtle motion that plays while an element is just sitting there, waiting to be interacted with.
Line drawing
An SVG path that draws itself in, like an invisible pen tracing it.
Orchestration
Deliberately timing multiple animations so they feel like one coordinated motion.

Related Components

Appears In