Skip to content

connect

connect(channel?, options?): Promise<Play>

Waits for the host (the Fabi Play screen around the game’s frame) to start the game, and resolves with the game’s Play. Rejects after 10 seconds without a host (the page was not opened from Fabi Play or its simulator), or if the host speaks another protocol version.

Channel

ConnectOptions

Promise<Play>

import { connect } from '@fabiplay/sdk'
const play = await connect()
play.on('gesture', ({ player, gesture }) => gesture === 'jump' && jump(player))
play.ready()