# RoomDefinition: tickRate property

> The tickRate property of a room definition gives the room ticks, run that many times a second.

The **`tickRate`** property of a [room definition](/docs/room/room-definition) gives the room ticks: it runs [`onTick()`](/docs/room/room-definition/ontick) that many times a second and sends what changed once per tick.

## Value

An integer from 1 to 120, the ticks per second. Without one, the room has no ticks.

## Exceptions

`defineRoom()` throws a `RangeError` for a `tickRate` that isn't an integer from 1 to 120. It throws an `Error` for a definition without one that has [`onTick()`](/docs/room/room-definition/ontick), a [`stepper`](/docs/room/room-definition/stepper), a [`history`](/docs/room/room-definition/history), or a [bot behaviour](/docs/room/room-definition/bots) with a `tick` hook. The types reject those too.

## Description

Give a room a `tickRate` when it simulates: something changes every moment whether or not players act, as in physics, movement that clients predict or interpolate, or a timer counted in ticks.

Leave it out when the room only changes because a player did something, as in a board, card or turn-based game, a chat or a shared editor. A room without ticks sends what its code changed as soon as that code yields, so a move reaches the other players one round trip after the player made it, and it costs nothing while nothing happens. Its `room.tick` stays 0 and `room.tickRate` is 0.

Ticks run with a fixed timestep, `1 / tickRate` seconds, which `onTick` and the stepper get as `dt`. After a stall a room runs at most 4 ticks to catch up and drops the rest. Ticks stop while the room is hibernated.

## Examples

### A racing room at 30 ticks a second

```ts
// race.ts
import { defineRoom, defineSchema, entity } from "@irtio/room";

const Race = entity("race", { lap: "u8", elapsed: "f64" });

export default defineRoom({
  schema: defineSchema({ state: Race }),
  tickRate: 30,
  onTick(room, dt) {
    room.state.elapsed += dt;
  },
});
```

## See also

- [With or without ticks](/docs/room/sdk#with-or-without-ticks)
- [`Room.tick`](/docs/room/room/tick)
- [Ticks](/docs/room/sdk#ticks)
