Client/React/useSharedPresence

useSharedPresence() API Docs

Kitchen-sink Example

Here's an example of using the hook with all the options and returns displayed.

export function MaxedOut() {
    const {

        self,              // this client's data
        setDynamicState,   // set this client's dynamic state
        others,            // everyone else's data (but not this client's)
        summary,           // the number of peers that are online and focused
        setFocus,          // set if this client is currently on the page and active

    } = useSharedPresence<TOptionalTypeOfDynamicState>({

        peerKey: `email-or-something-idk`,  // any string that uniquely identifies the user.
        roomKey: 'a-specific-room-key',     // if you don't want airstate to infer from url
        token: 'jwt-signed-by-your-server', // to maintain authentication & authorization
        client: customClient,               // if you don't use to use the default client with default config

        initialDynamicState: {
            x: 0,
            y: 0,
        },

    });

    return <>{/* ... */}</>
}

API

WIP.