# @react-three/xr

> VR/AR for react-three-fiber

Latest version **6.6.30** (published 2026-05-29) · SEE LICENSE IN LICENSE license · 0 weekly downloads

## Install

```sh
npm install @react-three/xr
pnpm add @react-three/xr
yarn add @react-three/xr
bun add @react-three/xr
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 6.6.30 |
| Published | 2026-05-29 |
| First published | 2020-09-26 |
| Weekly downloads | 0 |
| License | SEE LICENSE IN LICENSE |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 169.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 2608 |
| Author | Bela Bohlender |
| Maintainers | sniok, drcmda, codyjasonbennett, bela-bohlender |
| Keywords | r3f, xr, ar, vr, three.js, react, typescript |

## Links

- npm: https://www.npmjs.com/package/@react-three/xr
- Repository: https://github.com/pmndrs/xr
- Issues: https://github.com/pmndrs/xr/issues
- npm.io page: https://npm.io/package/@react-three/xr

## Dependencies (5)

- [zustand](https://npm.io/package/zustand.md) ^4.5.2
- [@pmndrs/xr](https://npm.io/package/@pmndrs/xr.md) ~6.6.30
- [tunnel-rat](https://npm.io/package/tunnel-rat.md) ^0.1.2
- [suspend-react](https://npm.io/package/suspend-react.md) ^0.1.3
- [@pmndrs/pointer-events](https://npm.io/package/@pmndrs/pointer-events.md) ~6.6.30

## Alternatives

- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) — 962.4K weekly downloads
- [mmdb-lib](https://npm.io/package/mmdb-lib.md) — 680.9K weekly downloads
- [playcanvas](https://npm.io/package/playcanvas.md) — 36.2K weekly downloads
- [@glw907/cairn-cms](https://npm.io/package/@glw907/cairn-cms.md) — 967 weekly downloads
- [markdown-to-confluence](https://npm.io/package/markdown-to-confluence.md) — 103 weekly downloads

## Recent versions

- 6.6.30 (latest) — 2026-05-29
- 6.5.1-alpha.2 (alpha) — 2025-01-21
- 6.6.29 — 2026-01-06
- 6.6.28 — 2025-11-20
- 6.6.27 — 2025-10-05
- 6.6.26 — 2025-09-09
- 6.6.25 — 2025-08-19
- 6.6.24 — 2025-08-19
- 6.6.23 — 2025-08-19
- 6.6.22 — 2025-08-05
- 6.6.21 — 2025-08-05
- 6.6.20 — 2025-07-19
- 6.6.19 — 2025-07-09
- 6.6.18 — 2025-07-08
- 6.6.17 — 2025-05-17
- … 124 more at https://npm.io/package/@react-three/xr/versions

## README

<p align="center">
  <img src="./docs/getting-started/logo.svg" width="100" />
</p>

<h1 align="center">xr</h1>
<h3 align="center">Turn any R3F app into an interactive immersive experience.</h3>
<br/>

<p align="center">
  <a href="https://npmjs.com/package/@react-three/xr" target="_blank">
    <img src="https://img.shields.io/npm/v/@react-three/xr?style=flat&colorA=000000&colorB=000000" alt="NPM" />
  </a>
  <a href="https://npmjs.com/package/@react-three/xr" target="_blank">
    <img src="https://img.shields.io/npm/dt/@react-three/xr.svg?style=flat&colorA=000000&colorB=000000" alt="NPM" />
  </a>
  <a href="https://twitter.com/pmndrs" target="_blank">
    <img src="https://img.shields.io/twitter/follow/pmndrs?label=%40pmndrs&style=flat&colorA=000000&colorB=000000&logo=twitter&logoColor=000000" alt="Twitter" />
  </a>
  <a href="https://discord.gg/ZZjjNvJ" target="_blank">
    <img src="https://img.shields.io/discord/740090768164651008?style=flat&colorA=000000&colorB=000000&label=discord&logo=discord&logoColor=000000" alt="Discord" />
  </a>
</p>

```bash
npm install three @react-three/fiber @react-three/xr@latest
```

## What does it look like?

| A simple scene with a mesh that toggles its material color between `"red"` and `"blue"` when clicked through touching or pointing. | ![recording of interacting with the code below](./docs/getting-started/basic-example.gif) |
| ---------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |

```tsx
import { Canvas } from '@react-three/fiber'
import { XR, createXRStore } from '@react-three/xr'
import { useState } from 'react'

const store = createXRStore()

export function App() {
  const [red, setRed] = useState(false)
  return (
    <>
      <button onClick={() => store.enterAR()}>Enter AR</button>
      <Canvas>
        <XR store={store}>
          <mesh pointerEventsType={{ deny: 'grab' }} onClick={() => setRed(!red)} position={[0, 1, -1]}>
            <boxGeometry />
            <meshBasicMaterial color={red ? 'red' : 'blue'} />
          </mesh>
        </XR>
      </Canvas>
    </>
  )
}
```

### How to enable XR for your @react-three/fiber app?

1. `const store = createXRStore()` create a xr store
2. `store.enterAR()` call enter AR when clicking on a button
3. `<XR>...</XR>` wrap your content with the XR component

... or read this guide for [converting a react-three/fiber app to XR](https://docs.pmnd.rs/xr/getting-started/convert-to-xr).

## Tutorials

- 💾 [Store](https://docs.pmnd.rs/xr/tutorials/store)
- 👆 [Interactions](https://docs.pmnd.rs/xr/tutorials/interactions)
- 👌 [Handles](https://docs.pmnd.rs/xr/handles/introduction)
- 🔧 [Options](https://docs.pmnd.rs/xr/tutorials/options)
- 🧊 [Object Detection](https://docs.pmnd.rs/xr/tutorials/object-detection)
- ✴ [Origin](https://docs.pmnd.rs/xr/tutorials/origin)
- 🪄 [Teleport](https://docs.pmnd.rs/xr/tutorials/teleport)
- 🕹️ [Gamepad](https://docs.pmnd.rs/xr/tutorials/gamepad)
- ➕ [Secondary Input Sources](https://docs.pmnd.rs/xr/tutorials/secondary-input-sources)
- 📺 [Layers](https://docs.pmnd.rs/xr/tutorials/layers)
- 🎮 [Custom Controller/Hands/...](https://docs.pmnd.rs/xr/tutorials/custom-inputs)
- ⚓️ [Anchors](https://docs.pmnd.rs/xr/tutorials/anchors)
- 📱 [Dom Overlays](https://docs.pmnd.rs/xr/tutorials/dom-overlay)
- 🎯 [Hit Test](https://docs.pmnd.rs/xr/tutorials/hit-test)
- ⛨ [Guards](https://docs.pmnd.rs/xr/tutorials/guards)

## External Tutorials

- 🥇 [**WebXR First Steps React** by Meta Quest](https://github.com/meta-quest/webxr-first-steps-react)

## Roadmap

- 🤳 XR Gestures
- 🕺 Tracked Body

## Migration guides

- from [@react-three/xr v5](https://docs.pmnd.rs/xr/migration/from-react-three-xr-5)
- from [natuerlich](https://docs.pmnd.rs/xr/migration/from-natuerlich)

## Sponsors

This project is supported by a few companies and individuals building cutting-edge 3D Web & XR experiences. Check them out!

![Sponsors Overview](https://bbohlender.github.io/sponsors/screenshot.png)

---
_Source: https://npm.io/package/@react-three/xr · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
