This section provides practical examples demonstrating how to use kSync in real-world applications. Each example includes complete, runnable code with explanations.
# Terminal 1: Start the game servercd examples/nextjs-gamebun run server.ts# Terminal 2: Start the Next.js appbun run dev# Open http://localhost:3000 in multiple tabs
// Events are automatically batchedconst promises = users.map(user => ksync.send('user-joined', { userId: user.id }));await Promise.all(promises); // Sent as single batch