Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 3 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

Matter.js

2D rigid body physics engine for web and game development.

Game developmentNPM

GitHubWebsite

1. License

License from npm.

github.com/liabru/matter-js

From the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error

What Matter.js does

Matter.js is an original JavaScript 2D rigid body engine, not a port, that ships its own canvas renderer and a long list of live demos whose source sits in the repo.

Matter.js popularity

56 / 100
Gid Score, #1368 overall
586K
downloads a week, npm
18.7K
GitHub stars
5
agent projects use it
Matter.js: downloads per weeknpm, matter-js 586,311
Matter.js: GitHub starsliabru/matter-js 18,674

Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated

How Matter.js is used

  • Matter.js is a dependency in 5 of the 6,258 public GitHub projects set up for AI coding agents that we scanned, too few to describe it from them alone. Our scan also samples projects by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750); counting those, it appears in 34 projects, and what it is used with below comes from all of them.
  • The most used alternative in our scan is Phaser (12 projects).
  • Projects that use it most often also use Three.js (73.5%), React Three Fiber (70.6%), React (94.1%).

Often used with

In 73.5% of its projects
In 70.6% of its projects
In 94.1% of its projects
In 52.9% of its projects
In 52.9% of its projects
In 50.0% of its projects
In 44.1% of its projects
In 67.6% of its projects

Matter.js in practice

Strengths

Its own physics code, not a port

The README lists the engine as "An original JavaScript physics implementation (not a port)". The API is written for JavaScript from the start, not translated from another engine.

Browser and Node.js from one package

The feature list claims support for Chrome, Firefox, Safari and IE8+, plus Node.js. It also lists touch input and responsive layouts for mobile.

More than boxes and circles

The feature list covers compound and composite bodies and concave and convex hulls. There is a demo that builds bodies from concave SVG paths.

Raycasting, views and slow motion included

Collision queries (raycasting and region tests), camera-like views with translate and zoom, and time scaling are all part of the core feature list.

Watch out for

Dev-mode tooling can slow the simulation

The README warns that bundlers and frameworks may reduce real-time performance with their default configs, especially in development modes.

Webpack sourcemaps and Vue watchers

The README names two specific culprits: Webpack's default sourcemap config and Vue.js watchers. It points to GitHub issue #1001 for fixes, not to a setting in the library itself.

Saving world state needs another library

World state serialisation is listed as a feature, but it requires the separate resurrect.js project.

Install from npm

npm install matter-js

More about Matter.js

Packages around it
  • three: 3D rendering
  • @react-three: Three.js in React
  • react: UI library
  • framer-motion: React animation
  • react-router-dom: Client routing
  • gsap: Tween animation
More in Game development

Alternatives

Matter.js This page

MITGid 56586K/wk

Phaser

Fast, free HTML5 game framework for building 2D games for desktop and mobile.

MITGid 71778K/wk

Compare Matter.js with another tool

Get started

Install it.

npm install matter-js

Rules for your agent

Paste into AGENTS.md or CLAUDE.md
## Matter.js
- Install with `npm install matter-js`. If you load it with a script tag, use a stable release from the tags, not the experimental alpha build on master.
- Start from the Getting started wiki page. Its minimal example is meant to run in both browsers and Node.js.
- When the project has its own game or render loop, follow the Running and Rendering wiki pages instead of assuming the built-in canvas renderer.
- If the simulation stutters in development, check the bundler before the physics. Webpack's default sourcemap config and Vue.js watchers are known causes (see issue #1001).
- World state serialisation needs resurrect.js. Add it explicitly before saving or restoring worlds.
- Before writing a feature from scratch, look for the matching demo in the repo's `examples` directory, then for a plugin in the wiki's List of plugins.

AgentGid articles about Matter.js

All guides