Repolode
liabru

liabru/matter-js

A 2D rigid body physics engine for the web, written in JavaScript and running in browsers and Node.js.

Stars
18,600
Forks
2,000
Open issues
280
Last commit
last month

What is it?

Matter.js is a 2D rigid body physics engine written in JavaScript for the web. It handles collisions, gravity, friction, restitution and constraints, so developers can add believable physical motion to canvas-based games, interactive graphics and simulations without writing their own physics code.

The engine supports rigid, compound and concave bodies, including shapes built from SVG paths and terrain. It provides collision queries such as raycasting and region tests, time scaling for slow-motion effects, views with zoom and translation, and a canvas renderer that can draw vectors and textures. Bodies can be put to sleep when resting, and world state can be serialised with the help of resurrect.js.

Matter.js runs in Chrome, Firefox, Safari and IE8+, as well as in Node.js. It is installable through npm or Yarn, can be included with a single script tag, and has a plugin system along with a broad set of demos and an API reference.

Key features

  • 01Rigid, compound and concave bodies with collision detection
  • 02Gravity, friction, restitution and constraints
  • 03Raycasting and region queries for collision checks
  • 04Canvas renderer supporting vector shapes and textures
  • 05Time scaling, views with zoom, and sleeping bodies
  • 06Plugin system, runs in browsers and Node.js

Use cases

  • Building 2D physics games such as slingshot or stacking puzzles in the browser
  • Adding interactive physical motion to canvas-based web animations
  • Running headless physics simulations in Node.js
  • Prototyping mechanical systems like bridges, cars or pendulums

Quick start

  1. 1

    Install the package from npm

    npm install matter-js
  2. 2

    Follow the Getting started wiki page for a minimal usage example

Things to know

  • The README labels the alpha build from master as experimental.

In collections

Topics

FAQ

What is matter-js?
A 2D rigid body physics engine for the web, written in JavaScript and running in browsers and Node.js. Matter.js is a 2D rigid body physics engine written in JavaScript for the web. It handles collisions, gravity, friction, restitution and constraints, so developers can add believable physical motion to canvas-based games, interactive graphics and simulations without writing their own physics code.
Is matter-js free to use? What license does it have?
matter-js is open source under the MIT license. Check the license terms before using it in commercial products.
Is matter-js still maintained?
Updated within 6 months. The last commit to matter-js was on Sep 30, 2026.
What can I use matter-js for?
Building 2D physics games such as slingshot or stacking puzzles in the browser Adding interactive physical motion to canvas-based web animations Running headless physics simulations in Node.js Prototyping mechanical systems like bridges, cars or pendulums
How do I install matter-js?
Install the package from npm: npm install matter-js Follow the Getting started wiki page for a minimal usage example
Where can I get matter-js?
The source code and installation instructions are on GitHub: https://github.com/liabru/matter-js

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects