This skill provides best practices for implementing features using Liveblocks packages like @liveblocks/react and @liveblocks/node. It's useful for developers working on realtime applications such as multiplayer games, commenting systems, and more.
$ npx skills add https://github.com/liveblocks/skills --skill liveblocks-best-practicesThe Liveblocks Best Practices skill provides comprehensive guidance for developers building realtime applications using Liveblocks packages like @liveblocks/react and @liveblocks/node. It contains over 40 references covering features, debugging, and common implementation patterns for multiplayer games, commenting systems, and other collaborative tools. The skill helps answer questions about handling unstable connections, passing custom headers, structuring data, and troubleshooting issues. Available as a plugin for Claude Code, Cursor, and other AI coding assistants, it integrates with the Agent Skills format for seamless access during development.
Install the skill using the provided npx command.
Real-time multiplayer features
Commenting systems
Notifications and cursors
Avatar stacks implementation
$ npx skills add https://github.com/liveblocks/skills --skill liveblocks-best-practicesgit clone https://github.com/liveblocks/skillsCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Provide best practices for implementing [FEATURE] using Liveblocks packages like @liveblocks/react and @liveblocks/node in a [COMPANY] [INDUSTRY] application. Focus on performance, security, and scalability. Include code snippets if applicable.
**Liveblocks Best Practices for a Collaborative Whiteboard App**
### 1. **Room Management**
- Always clean up unused rooms to avoid memory leaks. Use `room.leave()` when a user exits the whiteboard.
- Prefix room IDs with the user’s ID (e.g., `whiteboard_${userId}`) to ensure uniqueness.
### 2. **Authorization & Security**
- Validate user permissions in your `@liveblocks/node` auth endpoint. Example:
```javascript
export const authEndpoint = async (request) => {
const session = await validateSession(request);
if (!session.isPremiumUser) throw new Error("Unauthorized");
return { userId: session.id };
};
```
### 3. **Optimizing Performance**
- Use `shouldThrottle` in `useStorage()` to reduce re-renders:
```javascript
const others = useOthers({ shouldThrottle: 100 });
```
- Batch updates with `useMutation()` to minimize network calls.
### 4. **Error Handling**
- Wrap Liveblocks hooks in error boundaries to catch connection issues gracefully.
- Log errors to Sentry or similar tools for debugging.
### 5. **Scalability**
- For large teams, partition rooms by project (e.g., `project_${projectId}`) to distribute load.
Need more details on a specific area?Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan