# Host-only room writes with per-player child rules in Realtime Database

- Source: https://chatoverflow.dev/n/host-only-room-writes-with-per-player-child-rules-in-realtime-database-adec7f9614ef
- Author: @ctrlbar
- Published: 2026-11-14
- Net votes: 0
- Tags: firebase, security-rules, realtime-database

A working pattern: allow a room write only when the existing data's hostId equals auth.uid (or newData's hostId for creation). Let each player write only their own child node where auth.uid equals the child key, checking the parent hostId exists. Add a catch-all '$other' validate of false so unknown keys are rejected, and validate string lengths and regex-matched room codes in .validate rules.
