npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-usa-map-modern

v3.0.2

Published

React component with all USA States with customizable options

Readme

react-usa-map-modern

A simple, customizable SVG USA map component for React.

Note: This is a modernized fork of react-usa-map by Gabriela D'Avila Ferrara. This fork updates the project to current standards with TypeScript, modern React patterns, and ESM/CJS dual packaging.

Features

  • All 50 US states plus DC, Alaska, and Hawaii
  • Customizable colors per state
  • Custom click handlers per state
  • TypeScript support with full type definitions
  • No D3 dependency - lightweight and fast
  • Uses the Albers projection

Installation

Requires React 17, 18, or 19.

npm install react-usa-map-modern

Usage

Basic Example

import USAMap from "react-usa-map-modern";

function App() {
  const handleClick = (stateAbbreviation: string) => {
    alert(`You clicked ${stateAbbreviation}`);
  };

  return <USAMap onClick={handleClick} />;
}

With Customization

import USAMap from "react-usa-map-modern";

function App() {
  const handleClick = (stateAbbreviation: string) => {
    console.log(`Clicked: ${stateAbbreviation}`);
  };

  const statesCustomization = {
    NJ: {
      fill: "navy",
      clickHandler: (state: string) => console.log(`Custom handler for ${state}`),
    },
    NY: {
      fill: "#CC0000",
    },
  };

  return (
    <USAMap
      customize={statesCustomization}
      onClick={handleClick}
      defaultFill="#E8E8E8"
    />
  );
}

Styling Hover States

path.state {
  pointer-events: all;
}
path.state:hover {
  opacity: 0.5;
  cursor: pointer;
}

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | onClick | (stateAbbreviation: string) => void | - | Called when a state is clicked | | width | number | 959 | SVG width | | height | number | 593 | SVG height | | title | string | "Blank US states map" | SVG title attribute | | defaultFill | string | "#D3D3D3" | Default fill color for states | | customize | StatesCustomization | {} | Per-state customization (see below) |

Customization Object

type StatesCustomization = {
  [stateAbbreviation: string]: {
    fill?: string;
    clickHandler?: (stateAbbreviation: string) => void;
  };
};

TypeScript

Type definitions are included. You can import types directly:

import USAMap, { USAMapProps, StatesCustomization } from "react-usa-map";

HTML Structure

Each state is rendered as an SVG path with the state abbreviation as a class:

<path class="CA state" data-name="CA" fill="#D3D3D3" d="..."></path>

License

MIT

Sources

The map is sourced from Wikimedia under CC BY-SA 3.0.