<?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: vivek gupta</title>
    <description>The latest articles on DEV Community by vivek gupta (@vivek_gupta_09ca2a9643bf2).</description>
    <link>https://dev.to/vivek_gupta_09ca2a9643bf2</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%2F3719938%2Fc0248ff5-5f53-454d-9c7a-a077a5c4aa4c.jpg</url>
      <title>DEV Community: vivek gupta</title>
      <link>https://dev.to/vivek_gupta_09ca2a9643bf2</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vivek_gupta_09ca2a9643bf2"/>
    <language>en</language>
    <item>
      <title>How NinjaType runs real-time multiplayer races on Cloudflare's free tier ?</title>
      <dc:creator>vivek gupta</dc:creator>
      <pubDate>Sat, 05 Dec 2026 07:10:29 +0000</pubDate>
      <link>https://dev.to/vivek_gupta_09ca2a9643bf2/how-ninjatype-runs-real-time-multiplayer-races-on-cloudflares-free-tier--g3</link>
      <guid>https://dev.to/vivek_gupta_09ca2a9643bf2/how-ninjatype-runs-real-time-multiplayer-races-on-cloudflares-free-tier--g3</guid>
      <description>&lt;p&gt;A multiplayer race needs a scoreboard that updates every second. The obvious way to build that is a game server with a tick loop, presence heartbeats, and per-keystroke streaming. NinjaType's &lt;a href="https://www.ninjatype.com/multiplayer-typing-race/" rel="noopener noreferrer"&gt;multiplayer typing race&lt;/a&gt; has none of that. It runs on Cloudflare Workers &lt;strong&gt;Free&lt;/strong&gt;, in front of a fully static Astro site, with no accounts and no keystroke uploads — and the standings still update about once a second.&lt;/p&gt;

&lt;p&gt;This post is about the pieces that made that possible: WebSocket hibernation with state in socket attachments, report-driven broadcasts instead of a server tick, an admissions pipeline built on Turnstile receipts, and a room directory that fits in ~480 KV writes a day. The whole backend lives in &lt;a href="https://github.com/VivekGupta137/ninjatype/tree/main/workers/multiplayer" rel="noopener noreferrer"&gt;&lt;code&gt;workers/multiplayer/&lt;/code&gt;&lt;/a&gt; — about 1,200 lines including tests.&lt;/p&gt;

&lt;h2&gt;
  
  
  The shape of the system
&lt;/h2&gt;

&lt;p&gt;The Astro site stays static on Cloudflare Pages. A service binding points Pages at the Worker; a Pages Function forwards only &lt;code&gt;/api/multiplayer/*&lt;/code&gt;, and &lt;code&gt;_routes.json&lt;/code&gt; keeps every other request on static asset serving — practice traffic never touches dynamic compute. (Custom-domain requests use Worker routes directly and skip the forward hop.)&lt;/p&gt;

&lt;p&gt;Inside the Worker there are exactly two Durable Objects, both on the SQLite storage class:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;Room&lt;/code&gt;&lt;/strong&gt; — one object per room. Owns race state, the WebSocket server end, and the alarm that fires deadlines.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;Directory&lt;/code&gt;&lt;/strong&gt; — one global object for room discovery: a SQLite table plus one batched KV snapshot.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Browser ──WS──▶ Room DO (per room)          ──▶ Directory DO (global)
   │                ▲ storage: SQLite           ▲ SQL rows + KV snapshot (3 min)
   └── progress ────┘                           └──▶ KV (public room list)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Hibernation instead of a game loop
&lt;/h2&gt;

&lt;p&gt;Room sockets use hibernation: &lt;code&gt;ctx.acceptWebSocket(server)&lt;/code&gt; and the runtime wakes the DO only when a message arrives, a socket closes, or the alarm fires. Between messages, the object doesn't bill duration or hold memory. Everything "live" lives in &lt;strong&gt;socket attachments&lt;/strong&gt; — small per-connection objects that the runtime persists across hibernation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;Attachment&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;epoch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;commands&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;syncs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;controls&lt;/span&gt;&lt;span class="o"&gt;?:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;chats&lt;/span&gt;&lt;span class="o"&gt;?:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;progress&lt;/span&gt;&lt;span class="o"&gt;?:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;roundId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;correctChars&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;updatedAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;standingsBroadcast&lt;/span&gt;&lt;span class="o"&gt;?:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;roundId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That interface is the whole trick. Live typing progress and broadcast timestamps sit in attachments, never in room state and never in storage or KV. Authoritative state is written once per real transition (join, start, finish), and a single storage alarm covers every future deadline — countdown end, score collection, rematch window, room expiry. There is no interval running anywhere.&lt;/p&gt;

&lt;h2&gt;
  
  
  Report-driven broadcasts
&lt;/h2&gt;

&lt;p&gt;Clients don't stream keystrokes. Each racer uploads exactly one number — the current correct-character count — and even that is throttled to &lt;strong&gt;once per aligned one-second window&lt;/strong&gt;, computed from round start:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;round&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;startAt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="no"&gt;PROGRESS_MS&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// PROGRESS_MS = 1_000&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;progress&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;roundId&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="n"&gt;round&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;
    &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;progress&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;updatedAt&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;round&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;startAt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="no"&gt;PROGRESS_MS&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Unchanged counts are included on purpose, so pauses show up in each player's WPM trend instead of the curve silently flattening.&lt;/p&gt;

&lt;p&gt;And instead of a timer fanning out standings every second per room, an incoming report &lt;em&gt;is&lt;/em&gt; the trigger. When a report lands in a window that hasn't been published yet, the room sends one compact standings broadcast to everyone:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;lastBroadcast&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getWebSockets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;socket&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;attached&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;socket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;deserializeAttachment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nc"&gt;Attachment&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;attached&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;standingsBroadcast&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;roundId&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="n"&gt;round&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;attached&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;standingsBroadcast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;progress&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;roundId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;round&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;correctChars&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;command&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;correctChars&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;updatedAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;publish&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;lastBroadcast&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lastBroadcast&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;round&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;startAt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="no"&gt;PROGRESS_MS&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;ws&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;serializeAttachment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;publish&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* one standings message to every socket */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The cost of that design: the first broadcast in a window can carry slightly older reports from other players, so the live panel is approximate — final scores replace estimates when the race ends. Worst case is a handful of messages per second per room, with zero scheduled work keeping rooms alive.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the server will — and won't — trust
&lt;/h2&gt;

&lt;p&gt;No keystroke streaming means the server can't prove human typing, so it doesn't pretend to. The trust model is drawn explicitly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Progress reports are bounded (&lt;code&gt;0 ≤ correctChars ≤ text.length&lt;/code&gt;, safe integers) but &lt;strong&gt;never select a winner or populate final metrics&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Time mode races end at the deadline; the server recomputes displayed metrics from one final text/count payload, bounded at 16,384 characters.&lt;/li&gt;
&lt;li&gt;Words mode ends on the first &lt;em&gt;server-accepted&lt;/em&gt; completion.&lt;/li&gt;
&lt;li&gt;Tie-breaks use accuracy, then a stable participant ID; zero input produces no winner.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Server-side passage generation closes the "the text ran out" loophole. Time mode generates one shared passage sized above the accepted 1,000-WPM pace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ceil&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;duration&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// chars at 1,000 WPM + buffer&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's sent once in the round snapshot — no mid-race text fetches — and the client renders at most 60 nearby words as the cursor advances, so a 25,000-character passage costs nothing to display.&lt;/p&gt;

&lt;h2&gt;
  
  
  Admissions: Turnstile plus single-use receipts
&lt;/h2&gt;

&lt;p&gt;Room creation and &lt;strong&gt;every socket entry&lt;/strong&gt; — creator included, reconnects included — require a fresh Turnstile challenge. Siteverify gets an idempotency key derived from the operation, so a cached verification can't be replayed into a different room:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;digest&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`${action}:${name}:${token}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sb"&gt;`${digest.slice(0, 8)}-${digest.slice(8, 12)}-4${digest.slice(13, 16)}-a${digest.slice(17, 20)}-${digest.slice(20, 32)}`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A successful check returns a receipt &lt;code&gt;{ hash, kind, until, epoch, fingerprint }&lt;/code&gt;, persisted with the room and valid for five minutes. Replaying the same challenge hash returns &lt;code&gt;409 token_reused&lt;/code&gt; instead of a second room or connection — which also neutralizes cached Siteverify retries. The timestamp from Cloudflare must be fresh (−30s to +300s), the hostname must equal the origin's hostname, and the action must match. Cloudflare's public test keys are only accepted when both the request URL and browser origin are loopback and the exact test keys are configured — so "always-pass" keys can never admit production rooms.&lt;/p&gt;

&lt;p&gt;One detail I like: closed rooms keep only their receipts until the five-minute retry window expires, then &lt;code&gt;deleteAll()&lt;/code&gt; clears storage. The tombstone deliberately preserves replay protection even after everything else is gone.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rate limiting without a rate limiter
&lt;/h2&gt;

&lt;p&gt;Per-socket limits also live in attachments, on a rolling ten-second window: hard cap of 30 messages (exceeding it closes the socket), 10 control commands, 2 syncs, 2 chat messages. Progress has its own aligned-window throttle on top. No shared rate-limiter service, no KV counters — the attachment resets itself whenever the window rolls.&lt;/p&gt;

&lt;h2&gt;
  
  
  The directory: SQL rows, one KV snapshot
&lt;/h2&gt;

&lt;p&gt;Discovery is a single global DO with a SQLite table, plus one batched publication to KV every three minutes (~480 writes/day — comfortably inside Free-tier limits):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'DELETE FROM rooms WHERE expiresAt &amp;lt;= ?'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;rooms&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'SELECT name, epoch, createdAt, expiresAt, maxPlayers FROM rooms ORDER BY createdAt DESC'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;ROOM_DIRECTORY&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'public-v1'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;publishedAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rooms&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;expirationTtl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;600&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Listings are hints, not truth: joining always validates live room existence, epoch, and capacity against the Room DO. Registration is an upsert guarded by &lt;code&gt;createdAt&lt;/code&gt;, so a stale registration can't overwrite a newer epoch of the same room.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fail closed, tell the truth
&lt;/h2&gt;

&lt;p&gt;The rule I'm proudest of is in &lt;code&gt;persist()&lt;/code&gt;: if storage or the alarm write fails, the room closes every socket with &lt;code&gt;1011 Multiplayer unavailable&lt;/code&gt; and stops acknowledging anything — it will never confirm an in-memory transition it couldn't save:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Never acknowledge an in-memory transition after storage/alarm failure.&lt;/span&gt;
    &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;unavailable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;ws&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getWebSockets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;ws&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1011&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Multiplayer unavailable; keep practicing'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* Already closed. */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The client-side counterpart: Quick race runs entirely in the browser with the same deterministic engine — seeded bots pacing 40–85 WPM in bursts with randomized pauses — and falls back to local practice whenever config, admission, or reconnection fails. Multiplayer being down degrades to "you can still practice," never to a broken screen.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it can't do
&lt;/h2&gt;

&lt;p&gt;Honest limits: the server can't distinguish a fast human from a script without keystroke streaming (it bounds and validates, but proof isn't on the menu); the single-directory KV snapshot needs partitioning before the room count gets large; and Free-tier request/storage quotas bound total capacity — Turnstile and throttling reduce abuse, they don't lift quotas. Reconnects also always require a fresh challenge, by design: a stale tab can't silently reattach.&lt;/p&gt;




&lt;p&gt;Try the result at the &lt;a href="https://www.ninjatype.com/multiplayer-typing-race/" rel="noopener noreferrer"&gt;multiplayer typing race&lt;/a&gt; — or race your own saved pace in &lt;a href="https://www.ninjatype.com/ghost-race/" rel="noopener noreferrer"&gt;Ghost Race&lt;/a&gt;. &lt;a href="https://www.ninjatype.com/" rel="noopener noreferrer"&gt;NinjaType&lt;/a&gt; is free, and the &lt;a href="https://github.com/VivekGupta137/ninjatype" rel="noopener noreferrer"&gt;source is on GitHub&lt;/a&gt;, including the Room/Directory objects and the engine tests.&lt;/p&gt;

&lt;p&gt;What would you trade for hibernation in your next real-time feature — eventual consistency in the live panel, or a challenge on every reconnect?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Disclosure: I'm NinjaType's creator.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>backend</category>
      <category>cloud</category>
      <category>webdev</category>
    </item>
    <item>
      <title>I built NinjaType: open-source typing practice with per-key feedback</title>
      <dc:creator>vivek gupta</dc:creator>
      <pubDate>Wed, 28 Oct 2026 07:20:31 +0000</pubDate>
      <link>https://dev.to/vivek_gupta_09ca2a9643bf2/i-built-ninjatype-open-source-typing-practice-with-per-key-feedback-3ck3</link>
      <guid>https://dev.to/vivek_gupta_09ca2a9643bf2/i-built-ninjatype-open-source-typing-practice-with-per-key-feedback-3ck3</guid>
      <description>&lt;p&gt;A typing test can tell you your words per minute and overall accuracy. But those two numbers leave a useful question unanswered: &lt;strong&gt;which keys should you practise next?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I'm Vivek Gupta, the creator of &lt;a href="https://www.ninjatype.com/" rel="noopener noreferrer"&gt;NinjaType&lt;/a&gt;, a free, open-source typing practice app. It combines typing tests with focused finger lessons, per-key feedback, and ways to make practice more engaging.&lt;/p&gt;

&lt;p&gt;For fellow developers, here's a look at the learning experience and the implementation choices behind it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start with two keys, then expand
&lt;/h2&gt;

&lt;p&gt;A large catalogue of drills can make it hard to choose where to start. NinjaType keeps the finger curriculum compact: four finger pairs, with three cumulative levels each.&lt;/p&gt;

&lt;p&gt;The index-finger path starts with just &lt;strong&gt;F and J&lt;/strong&gt;. Level two adds G, H, R, U, T, and Y; level three adds V, B, N, and M. The earlier keys stay in the later drills so progression still reinforces the basics.&lt;/p&gt;

&lt;p&gt;The other paths follow the same pattern:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Finger pair&lt;/th&gt;
&lt;th&gt;Start with&lt;/th&gt;
&lt;th&gt;Level two adds&lt;/th&gt;
&lt;th&gt;Level three adds&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Middle&lt;/td&gt;
&lt;td&gt;D, K&lt;/td&gt;
&lt;td&gt;E, I&lt;/td&gt;
&lt;td&gt;C, comma&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ring&lt;/td&gt;
&lt;td&gt;S, L&lt;/td&gt;
&lt;td&gt;W, O&lt;/td&gt;
&lt;td&gt;X, period&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pinky&lt;/td&gt;
&lt;td&gt;A, semicolon&lt;/td&gt;
&lt;td&gt;Q, P&lt;/td&gt;
&lt;td&gt;Z, slash&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;To unlock the next level, a completed session needs &lt;strong&gt;10 stars and at least 95% accuracy&lt;/strong&gt;. Stars reflect the session's speed and accuracy rating; they aren't a currency accumulated by repeating easy attempts. Each new level starts with zero stars and its own records.&lt;/p&gt;

&lt;p&gt;Previously unlocked levels remain available to retake. A replay can improve your results without moving your saved learning progress backwards.&lt;/p&gt;

&lt;p&gt;You can explore the paths in the &lt;a href="https://www.ninjatype.com/learn/" rel="noopener noreferrer"&gt;touch typing lessons&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Make the keyboard useful feedback
&lt;/h2&gt;

&lt;p&gt;The learning keyboard has two views: &lt;strong&gt;Key latency&lt;/strong&gt; and &lt;strong&gt;Accuracy&lt;/strong&gt;. Practised keys get subtle border and fill colors, ranging from soft red to green. Hovering or focusing a key reveals the actual readings and sample counts.&lt;/p&gt;

&lt;p&gt;The colors use the app's existing theme variables, including &lt;code&gt;--error-color&lt;/code&gt;, &lt;code&gt;--success-color&lt;/code&gt;, and &lt;code&gt;--bg-color&lt;/code&gt;. That keeps the feedback consistent with the selected theme and avoids introducing a separate palette just for analytics.&lt;/p&gt;

&lt;p&gt;Unmeasured keys stay neutral. Missing data shouldn't look like perfect accuracy or instant typing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Measuring a key is trickier than counting keystrokes
&lt;/h2&gt;

&lt;p&gt;Each key's learning metrics track four values:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;LearnKeyMetric&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;attempts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;latencySamples&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;totalLatencyMs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The display reads them with explicit checks for missing samples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;readLearnKeyMetric&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;metric&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="nx"&gt;LearnKeyMetric&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;accuracy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;metric&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;attempts&lt;/span&gt;
    &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;metric&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;errors&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nx"&gt;metric&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;attempts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;
    &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;latency&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;metric&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;latencySamples&lt;/span&gt;
    &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;metric&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;totalLatencyMs&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nx"&gt;metric&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;latencySamples&lt;/span&gt;
    &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Mistakes are attributed to the &lt;strong&gt;intended key&lt;/strong&gt;, and correcting the text doesn't erase those mistakes from the per-key feedback. Otherwise, backspacing could hide the very keys a learner needs to work on.&lt;/p&gt;

&lt;p&gt;Latency is the average interval before a correct character press. It isn't a pure measurement of a finger's reaction time: the preceding key and typing rhythm also affect it. The first press has no interval to measure, pauses longer than five seconds are excluded, and zero-time batched inserts don't create timing samples.&lt;/p&gt;

&lt;p&gt;Completed attempts contribute to saved feedback for that finger and level. The current drill can be shown alongside those records without counting a completed attempt twice.&lt;/p&gt;

&lt;h2&gt;
  
  
  The stack and state boundaries
&lt;/h2&gt;

&lt;p&gt;NinjaType uses &lt;strong&gt;Astro, React, TypeScript, and Nanostores&lt;/strong&gt;, with Apache ECharts for charts. The site runs on Cloudflare Pages; multiplayer uses a separate Cloudflare Worker with Durable Objects.&lt;/p&gt;

&lt;p&gt;Learning state stays separate from the main typing-test state. A lesson's active level is fixed for the duration of its drill, even when finishing it unlocks the next one. This lets the learner inspect their result before starting a new drill with a fresh target.&lt;/p&gt;

&lt;p&gt;Learning progress and key feedback are saved in the browser. Normal typing practice and lessons don't require an account.&lt;/p&gt;

&lt;p&gt;Beyond lessons, there are timed typing tests, &lt;a href="https://www.ninjatype.com/multiplayer-typing-race/" rel="noopener noreferrer"&gt;multiplayer typing races&lt;/a&gt;, and a Ghost Race mode based on a saved personal benchmark.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it or inspect the code
&lt;/h2&gt;

&lt;p&gt;If you're learning touch typing, start with one finger pair and use the feedback to choose what to repeat. If you're building a learning tool, the distinction between current input, completed-attempt metrics, and saved progression may be useful in your own app.&lt;/p&gt;

&lt;p&gt;NinjaType is available under the GPLv3 license. The &lt;a href="https://github.com/VivekGupta137/ninjatype" rel="noopener noreferrer"&gt;source code is on GitHub&lt;/a&gt;, including the curriculum, learning stores, and per-key measurement logic.&lt;/p&gt;

&lt;p&gt;What feedback would help you choose your next typing drill: individual keys, common letter pairs, or something else?&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Disclosure: I'm NinjaType's creator. This article was drafted with AI assistance using the project's documentation and source code.&lt;/em&gt;&lt;/p&gt;

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