Overview
ReactTogether is the core context provider component that wraps your entire application (or specific parts) to enable real-time collaboration features. It establishes the connection to the Multisynq infrastructure and provides the context needed for all React Together hooks and components to function.
This component is required - All React Together functionality depends on being wrapped by the
ReactTogether component.Basic Usage
Props
ReactTogetherSessionParams
required
Configuration object for the collaboration session
React.ReactNode
required
Your application components that will have access to React Together features
boolean
default:"false"
Whether sessions should ignore the URL when determining session uniqueness
string
Custom user ID for the current user. If not provided, a random ID will be generated
(userId: string) => string
Function to generate user nicknames from user IDs. Defaults to extracting from ID
boolean
default:"false"
Whether to remember user IDs in localStorage for consistent identity across sessions
SessionParams
string
required
Your Multisynq API key for authentication
string
required
Unique identifier for your application
string
Name of the collaboration session. Can be overridden by URL parameters
string
Password for the session. Can be overridden by URL parameters
typeof ReactTogetherModel
Custom Croquet model class. Advanced use case for extending functionality
any
Additional data to pass to the view initialization
Examples
Basic App Setup
The most common way to use ReactTogether is to wrap your entire app:URL-Based Session Parameters
Allow users to join sessions via URL parameters:Custom User Management
Implement custom user identification and nickname generation:Multi-Room Application
Create different collaboration rooms within the same app:Environment-Based Configuration
Configure ReactTogether differently for development, staging, and production:Conditional Collaboration
Enable collaboration features only when needed:URL Parameters
ReactTogether automatically reads session parameters from URL query parameters:rtName- Session namertPwd- Session password
https://myapp.com/?rtName=team-session&rtPwd=secure123
When these parameters are present in the URL, they override the sessionParams.name and sessionParams.password props.
Session Uniqueness
By default, sessions are scoped to the URL origin and pathname to prevent accidental session sharing between different parts of your application. SetsessionIgnoresUrl={true} to allow sessions with the same name to be shared across different URLs.
User Management
User IDs
- If no
userIdis provided, React Together generates a random ID - When
rememberUsers={true}, user IDs are stored in localStorage for consistency - User IDs should be unique across your application
Nicknames
ThederiveNickname function converts user IDs into display names:
Best Practices
API Key Security
Session Management
Error Handling
Related Components
SessionManager- UI for managing sessionsChat- Ready-to-use chat componentConnectedUsers- Display connected users
Related Hooks
useIsTogether- Check connection statususeConnectedUsers- Get connected usersuseStateTogether- Shared state management