How To Add Live Cursors Into Any React App

Friday 29 August 2025
How To Add Live Cursors Into Any React App

Introduction

Live cursors are everywhere now—Figma, Google Docs, Linear. They're that little detail that makes apps feel collaborative instead of lonely.

Building them usually sucks. WebSockets, state sync, complex data structures. Most libraries force you to rewrite half your app or learn some new "reactive paradigm."

This guide shows you how to add live cursors to your React app without any of that. No new mental models, no architecture changes. Just a hook that works like useState but syncs across users.

Installation

We'll use SharedPresence from AirState to build our live cursors. It's designed to feel just like regular React state. Unlike SharedState though, clients can only modify their own state but read everyone else's state.

# we highly recommend pnpm, but npm works too
pnpm add @airstate/client @airstate/react

Configuration

You have two options for setting up AirState:

  1. Use AirState Cloud (easiest) - Create an account and get an App ID
  2. Self-host - Run the Docker image on your own infrastructure

We'll use the cloud approach for simplicity, but you can check the self-hosting docs if you prefer to run your own server.

// App.tsx

import { configure } from '@airstate/client';

configure({
    appId: '[your app id]',
});

Step by Step

Setting Up The Components

export function App() {
    return (
        <div className="realtive w-[600px] h-[450px]">
        </div>
    )
}

Modeling State

Tracking & Broadcasting Mouse Positions

Rendering Cursors

Identity & Colors

Handling Presence

Putting It Alltogether

The AirState Manifesto

The internet once promised magic. Of minds meeting across oceans; collaboration at the speed of light. Somehow reality intervened and we lost that magic. Lag, screen sharing, awkward remote desktop solutions run rampant with embedded real-time being a rarity.

Even in 2025, building real-time is still too hard, too fragile and often too complex.

We're on a mission to restore that magic; to make building real-time effortless. It's what the web was always meant to be.