Client/React/useSharedState

useSharedState() API Docs

Kitchen-sink Example

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

import {useSharedState} from '@airstate/react';

export function App() {
    const [

        state,     // the data everyone sees
        setState,  // change the data everyone sees
        isReady,   // if the first-sync has occurred or not

    ] = useSharedState<TOptionalTypeOfState>(

        { potato: 'brownish' },     // the initial state

        {
            key: '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 want to use the default client
        }
    );

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

API

WIP.