useIsHost

The host is the player who started the game. Another player can become host if the current host leaves the game, and this value changes automatically to reflect that.

Signature

function useIsHost(): boolean

Returns

boolean

Usage

import { useIsHost } from 'playroomkit'
 
function GameControls() {
  const isHost = useIsHost();
 
  return (
    <div>
      {isHost ? (
        <div>
          <h3>Host Controls</h3>
          <button>Start Game</button>
          <button>Reset Game</button>
        </div>
      ) : (
        <div>
          <p>Waiting for host to start the game...</p>
        </div>
      )}
    </div>
  );
}