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-matters

v0.3.0

Published

React bindings for [Matter.js](https://brm.io/matter-js/) — render any React component as a physics body.

Readme

React Matters

React bindings for Matter.js — render any React component as a physics body.

Installation

npm install react-matters matter-js

Quick Start

import { Container, Bounds, MouseConstraint, useBody } from "react-matters";

const Ball = ({ x, y }: { x: number; y: number }) => {
  const { ref, style, dragControls } = useBody<HTMLDivElement>({
    type: "circle",
    x,
    y,
    draggable: true,
  });

  return (
    <div
      ref={ref}
      style={style}
      {...dragControls()}
      className="w-16 h-16 bg-slate-800 rounded-full"
    />
  );
};

const Box = ({ x, y }: { x: number; y: number }) => {
  const { ref, style, dragControls } = useBody<HTMLDivElement>({
    type: "rectangle",
    x,
    y,
    rounded: 8,
    draggable: true,
  });

  return (
    <div
      ref={ref}
      style={style}
      {...dragControls()}
      className="w-16 h-20 bg-slate-600"
    />
  );
};

function App() {
  return (
    <Container
      style={{ width: "100vw", height: "100vh", position: "relative" }}
      initEngineOptions={{ gravity: { x: 0, y: 2 } }}
    >
      <Ball x={200} y={100} />
      <Ball x={400} y={150} />
      <Box x={300} y={200} />
      <Bounds />
      <MouseConstraint />
    </Container>
  );
}

API

<Container>

Wraps your physics scene. All hooks must be used inside a Container.

| Prop | Type | Description | | ------------------- | ------------------- | ----------------------------------------------- | | initEngineOptions | IEngineDefinition | Initial Matter.js engine options (e.g. gravity) | | ...rest | div props | Passed through to the wrapper <div> |

useBody<T>(props)

Creates a physics body from any HTML element. Returns { ref, style, matterBody, dragControls }.

| Prop | Type | Description | | ----------------- | ------------------------------ | ----------------------------------------------- | | type | "rectangle" \| "circle" | Body shape | | x | number | Initial x position | | y | number | Initial y position | | rounded | number | Corner radius (rectangles) or chamfer (circles) | | draggable | boolean | Enable drag interaction | | isStatic | boolean | Fixed in place | | isSensor | boolean | Detects collisions without physical response | | friction | number | Surface friction | | frictionStatic | number | Static friction | | frictionAir | number | Air resistance | | restitution | number | Bounciness | | density | number | Body density | | slop | number | Collision slop tolerance | | timeScale | number | Per-body time scaling | | collisionFilter | { category?, mask?, group? } | Collision filtering |

useConstraint(props)

Creates a physics constraint between two bodies, or between a body and a world point. Returns a ref to the Matter.js constraint.

// Pin body to a world point
useConstraint({ bodyA: matterBody, pointB: { x: 200, y: 100 }, stiffness: 1 });

// Connect two bodies with a spring
useConstraint({ bodyA: bodyA, bodyB: bodyB, stiffness: 0.02, length: 100 });

| Prop | Type | Description | | ------------------ | ---------- | -------------------------------------------------- | | bodyA | Body | First body | | bodyB | Body | Second body (omit for world constraint) | | pointA | { x, y } | Anchor offset on bodyA | | pointB | { x, y } | Anchor offset on bodyB, or world point if no bodyB | | length | number | Rest length | | stiffness | number | Stiffness (0–1) | | damping | number | Damping (0–1) | | angularStiffness | number | Angular stiffness |

<Bounds>

Adds invisible static walls around the container edges.

| Prop | Type | Default | Description | | ------------- | -------- | ------- | --------------- | | restitution | number | 0 | Wall bounciness | | friction | number | 0.5 | Wall friction |

<MouseConstraint>

Enables mouse/pointer interaction with physics bodies (click and drag any body).

useContainerSize()

Returns [width, height] of the container.

useEngine()

Returns the Matter.js Engine instance for advanced use cases.