Find your next open-source project

Search by name, purpose, or keyword, or paste a GitHub URL. Start with / to search agent skills (e.g. /pdf)

pmndrs/react-three-rapier

Developer Tools

React components that wrap the Rapier physics engine for building 3D scenes in react-three-fiber.

1,994
159
TypeScript
MIT
4 years old

What it does

@react-three/rapier wraps the Rapier WASM physics engine in React components so a react-three/fiber scene can get rigid bodies, colliders and joints without hand-managing the physics world. <Physics> creates the world, <RigidBody> puts a mesh into simulation, and colliders can be generated automatically from mesh geometry (cuboid, ball, trimesh, hull) or declared explicitly as compound shapes. It fits React developers building 3D games, simulations and interactive product scenes who want a small, declarative API.

Beyond the basics, the library covers collision and contact-force events, sensors, collision groups, six joint hooks (fixed, spherical, revolute, prismatic, rope, spring), instanced rigid bodies for large counts, manual stepping, on-demand rendering and world snapshots. Types that cross between Rapier and Three.js can be converted with helpers such as vec3, quat and euler.

Quick start

Install the package together with its react-three/fiber and Three.js peers:

npm install @react-three/rapier three @react-three/fiber @react-three/drei

Render a scene inside <Canvas> and wrap physics content in <Suspense>, because Rapier is loaded lazily:

import { Box, Torus } from "@react-three/drei";
import { Canvas } from "@react-three/fiber";
import { Physics, RigidBody, CuboidCollider } from "@react-three/rapier";

const App = () => (
  <Canvas>
    <Suspense>
      <Physics debug>
        <RigidBody colliders="hull" restitution={2}>
          <Torus />
        </RigidBody>
        <CuboidCollider position={[0, -2, 0]} args={[20, 0.5, 20]} />
      </Physics>
    </Suspense>
  </Canvas>
);

With debug enabled, colliders are drawn over the scene so you can verify shapes. The basic example appears in the project readme Basic Usage; interactive collider and joints demos are on CodeSandbox.

Version compatibility

v2 targets @react-three/fiber v9 and React 19. Projects on React 18 must stay on @react-three/rapier v1 with @react-three/fiber v8. Check the installed React version before copying current examples.

Usage constraints

  • <Physics> loads Rapier lazily, so it must sit under <Suspense>.
  • The default fixed time step is 60 FPS; timeStep="vary" follows frame deltas but can make simulation unstable and non-deterministic.
  • For collision filtering hooks, rigid-body state cannot be read during the physics step due to Rust aliasing rules; cache values in useBeforePhysicsStep first.
  • World snapshots restore correctly only when the object set and creation order match the snapshotted world.
  • Rigid bodies simulate in world space, so placing their center of gravity at the object center avoids odd interpolation behavior.
  • The licence is MIT.

HotRepo's take

The project is a mature member of the pmndrs ecosystem rather than a new experiment: it has existed since April 2022 and, on a daily TypeScript ranking dated 2026-12-04, recorded 76 new stars and placed 15th in that language list. That is a single snapshot, not a trend, but it shows the library still pulls attention from React and Three.js developers. The API depth — instanced bodies, joint hooks and collision filtering — makes it more than a thin wrapper, and the v2/v1 split is the main thing to check before adopting it in an existing app.

Written by AI from the project's public information and HotRepo's records, updated . The project's own docs are the source of truth.

You might also like

  1. react/react-nativeA framework for building real native iOS and Android apps with React, aimed at teams that want one JavaScript codebase.C++126,776
  2. Caho1/open-claude-uiA React/CSS component library that reconstructs Claude's desktop design system, including motion physics, from decompiled binaries.TypeScript1,398
  3. Secretmakewomenwomen/auric-uiA React 19 component library and coding-agent skill for building AI assistant workbenches and media editors.TypeScript100
  4. YusufCeng1z/dingA dependency-free spring-physics toast library with single-toast morphing, distributed for React, Svelte and plain DOM.TypeScript102
  5. nathanliow/atlas-of-physicsA browser-based 3D textbook that lets students scroll, hover and click through AP Physics motions chapter by chapter.JavaScript105