# r3f-perf

> Easily monitor your ThreeJS performances.

Latest version **7.2.3** (published 2024-11-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install r3f-perf
pnpm add r3f-perf
yarn add r3f-perf
bun add r3f-perf
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 7.2.3 |
| Published | 2024-11-08 |
| First published | 2021-01-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 357 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 783 |
| Author | Renaud ROHLINGER |
| Maintainers | onirenaud |
| Keywords | react, three, benchmark, performance, monitor, analysis, profiling, r3f |

## Links

- npm: https://www.npmjs.com/package/r3f-perf
- Repository: https://github.com/utsuboco/r3f-perf
- Issues: https://github.com/utsuboco/r3f-perf/issues
- npm.io page: https://npm.io/package/r3f-perf

## Dependencies (5)

- [zustand](https://npm.io/package/zustand.md) ~4.5.2
- [@utsubo/events](https://npm.io/package/@utsubo/events.md) ^0.1.7
- [@stitches/react](https://npm.io/package/@stitches/react.md) ^1.2.8
- [@react-three/drei](https://npm.io/package/@react-three/drei.md) ^9.103.0
- [@radix-ui/react-icons](https://npm.io/package/@radix-ui/react-icons.md) ^1.3.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 7.2.3 (latest) — 2024-11-08
- 2.0.0-beta (beta) — 2021-03-30
- 7.2.2 — 2024-10-03
- 7.2.1 — 2024-04-01
- 7.2.0 — 2024-04-01
- 7.1.2 — 2023-02-08
- 7.1.1 — 2023-02-05
- 7.1.0 — 2023-02-05
- 7.0.1 — 2023-01-31
- 7.0.0 — 2023-01-31
- 7.0.0-beta.1 — 2023-01-31
- 7.0.0-beta.0 — 2023-01-30
- 6.7.0 — 2023-01-29
- 6.6.3 — 2022-12-19
- 6.6.2 — 2022-12-19
- … 114 more at https://npm.io/package/r3f-perf/versions

## README

![npm](https://img.shields.io/npm/v/r3f-perf) ![npm](https://img.shields.io/npm/dw/r3f-perf)

# R3F-Perf

**[Changelog](https://github.com/utsuboco/r3f-perf/blob/main/CHANGELOG.md)**

Easily monitor the performances of your @react-three/fiber application.

<table>
  <tr>
    <td>Add the Perf component anywhere in your Canvas.</td>
    <td>
<a href="https://wtp9t.csb.app/">
  <img src="https://user-images.githubusercontent.com/15867665/215722804-3b4ee71c-d205-429b-8cae-f915bf60d56c.png" /></td>
</a>
  </tr>
</table>

## Installation

```bash
yarn add --dev r3f-perf
```

## Options

```jsx
logsPerSecond?: 10, // Refresh rate of the logs
antialias?: true, // Take a bit more performances but render the text with antialiasing
overClock?: false, // Disable the limitation of the monitor refresh rate for the fps
deepAnalyze?: false, // More detailed informations about gl programs
showGraph?: true // show the graphs
minimal?: false // condensed version with the most important informations (gpu/memory/fps/custom data)
customData?: {
  value: 0, // initial value,
  name: '', // name to show
  round: 2, // precision of the float
  info: '', // additional information about the data (fps/ms for instance)
}
matrixUpdate?: false // count the number of time matrixWorldUpdate is called per frame
chart?: {
  hz: 60, // graphs refresh frequency parameter
  length: 120, // number of values shown on the monitor
}
colorBlind?: false // Color blind colors for accessibility
className?: '' // override CSS class
style?: {} // override style
position?: 'top-right'|'top-left'|'bottom-right'|'bottom-left' // quickly set the position, default is top-right
```

## Usage

```jsx
import { Canvas } from '@react-three/fiber'
import { Perf } from 'r3f-perf'

function App() {
  return (
    <Canvas>
      <Perf />
    </Canvas>
  )
}
```

#### Usage without interface : PerfHeadless

[Codesandbox Example](https://codesandbox.io/s/perlin-cubes-r3f-perf-headless-mh1jl7?file=/src/App.js)

```jsx
import { Canvas } from '@react-three/fiber'
import { PerfHeadless, usePerf } from 'r3f-perf'

const PerfHook = () => {
  // getPerf() is also available for non-reactive way
  const [gl, log, getReport] = usePerf((s) => s[(s.gl, s.log, s.getReport)])
  console.log(gl, log, getReport())
  return <PerfHeadless />
}

function App() {
  return (
    <Canvas>
      <PerfHook />
    </Canvas>
  )
}
```

## Custom Data

```jsx
import { setCustomData, getCustomData } from 'r3f-perf'

const UpdateCustomData = () => {
  // recommended to throttle to 1sec for readability
  useFrame(() => {
    setCustomData(55 + Math.random() * 5) // will update the panel with the current information
  })
  return null
}
```

## SSR

The tool work with any server side rendering framework. You can try with Next and @react-three/fiber using this starter :
https://github.com/pmndrs/react-three-next

### Maintainers :

- [`twitter 🐈‍⬛ @onirenaud`](https://twitter.com/onirenaud)
- [`twitter @utsuboco`](https://twitter.com/utsuboco)

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