Synchronize state across all users in real-time. Works exactly like React’s useState but keeps all users in sync.
useStateTogether
is the core hook of React Together. It creates state that is automatically synchronized across all users in your session. It works exactly like React’s useState
, but any state changes are instantly shared with all connected users.
useState
:
useStateTogether
is fully typed and provides excellent TypeScript support:
State not synchronizing
key
parameterReactTogether
provider wraps all componentsFrequent re-renders
throttleDelay
in optionsuseMemo
or useCallback
for expensive computationsState resets unexpectedly
resetOnDisconnect
optionPerformance issues
useStateTogetherWithPerUserValues
for user-specific datauseStateTogether
is the foundation of React Together. Once you understand how it works, you can build any kind of collaborative feature by combining it with other hooks and components!