Home / Companies / Upstash / Blog / Post Details
Content Deep Dive

Figma-Style Live Cursors with Next.js 16 & Upstash Realtime

Blog post from Upstash

Post Details
Company
Date Published
Author
Josh
Word Count
2,082
Language
English
Hacker News Points
-
Summary

A detailed guide explains how to create real-time, Figma-style live cursors for a web application using Next.js, Upstash Realtime, and TypeScript. The process involves setting up a Realtime instance to batch cursor positions, which reduces network overhead and memory usage. A custom `useCursors` hook handles the batching of outgoing cursor positions and animates other users' cursors using `requestAnimationFrame` for smooth 60-FPS animations. Cursor components are developed to display other users' cursors and replace the current user's default cursor with a custom one. Utility functions are used for generating random usernames and consistent colors. The implementation includes setting up API routes to manage real-time events and integrating all components on the main page. The batching strategy is highlighted as an efficient and cost-effective method, with a suggestion to test the feature by opening the app in two browser windows to observe the live cursor interactions.