<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mert Kan</title>
    <description>The latest articles on DEV Community by Mert Kan (@mrttkan).</description>
    <link>https://dev.to/mrttkan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4283052%2F6c3e384c-597e-4d3a-a390-53d1bae36707.png</url>
      <title>DEV Community: Mert Kan</title>
      <link>https://dev.to/mrttkan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mrttkan"/>
    <language>en</language>
    <item>
      <title>I built a real-time multiplayer piano for the browser - here's the stack</title>
      <dc:creator>Mert Kan</dc:creator>
      <pubDate>Fri, 04 Dec 2026 15:01:42 +0000</pubDate>
      <link>https://dev.to/mrttkan/i-built-a-real-time-multiplayer-piano-for-the-browser-heres-the-stack-1jan</link>
      <guid>https://dev.to/mrttkan/i-built-a-real-time-multiplayer-piano-for-the-browser-heres-the-stack-1jan</guid>
      <description>&lt;p&gt;Over the last few months I've been building &lt;strong&gt;Social Piano&lt;/strong&gt;: a full 88-key piano that runs in the browser, where you can join a room and play together with other people in real time.&lt;/p&gt;

&lt;p&gt;You can try it here (no account needed to start playing): &lt;a href="https://socialpiano.com" rel="noopener noreferrer"&gt;https://socialpiano.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This post is a quick tour of the stack and a few decisions behind it, in case you're building something real-time yourself.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Play with your computer keyboard, mouse or touch screen, or plug in a USB/Bluetooth MIDI keyboard (Web MIDI)&lt;/li&gt;
&lt;li&gt;Live multiplayer rooms where everyone plays on the same keyboard, plus chat, friends and clans&lt;/li&gt;
&lt;li&gt;Several piano sounds with sustain pedal and reverb&lt;/li&gt;
&lt;li&gt;Record what you play and export it as a MIDI file&lt;/li&gt;
&lt;li&gt;A waterfall (falling notes) view and a song library with a step-by-step learning mode&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The stack
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Front end:&lt;/strong&gt; React + Vite. Sound comes from the Web Audio API and input from Web MIDI, so a real keyboard works with velocity in Chrome and Edge.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-time server:&lt;/strong&gt; a Node.js 24 WebSocket server built on &lt;code&gt;ws&lt;/code&gt;. It owns the rooms and relays note events to everyone else in the room. It also has rate limiting and a per-IP connection limit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data and auth:&lt;/strong&gt; Supabase (Postgres + Row Level Security + Auth) with ordered SQL migrations that are applied automatically from CI when they reach main.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sound packs:&lt;/strong&gt; piano samples live in Cloudflare R2 and are served through a small Cloudflare Worker that signs access, so the heavy audio files never touch the app server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mobile:&lt;/strong&gt; the same React app is wrapped with Capacitor for Android and iOS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hosting:&lt;/strong&gt; the web front end is on Vercel; the WebSocket server runs in Docker behind Caddy on a small cloud VM. GitHub Actions runs lint, tests, build and an end-to-end check on every push and deploys the server when its files change.&lt;/p&gt;

&lt;h2&gt;
  
  
  Design decisions
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Send notes, not audio.&lt;/strong&gt; The server only relays small note messages (key, velocity, on/off, sustain). Every client plays the sound locally, so bandwidth stays tiny and the server never deals with audio.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Validate everything on the server.&lt;/strong&gt; Every note event is validated, note-on floods are rate limited, the number of notes one player can hold down is capped, and only notes that were actually pressed can be released. A shared public keyboard needs this from day one.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Static pages for search.&lt;/strong&gt; The app itself is a single-page app, but the landing pages (virtual piano, multiplayer piano, learn piano, songs) are pre-rendered HTML in many languages, so they load instantly and are easy to index.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lots of tests for real-time logic.&lt;/strong&gt; The project has around 790 Node test runner tests plus a WebSocket end-to-end script, which makes it much safer to change room logic.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Try it and tell me what breaks
&lt;/h2&gt;

&lt;p&gt;I'm a solo developer, so honest feedback is gold:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How does latency feel when you play with someone far away?&lt;/li&gt;
&lt;li&gt;Is anything confusing in the first two minutes?&lt;/li&gt;
&lt;li&gt;Would you come back to play with friends?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Play: &lt;a href="https://socialpiano.com/multiplayer-piano" rel="noopener noreferrer"&gt;https://socialpiano.com/multiplayer-piano&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading!&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>react</category>
    </item>
  </channel>
</rss>
