<?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: OmarMusayev</title>
    <description>The latest articles on DEV Community by OmarMusayev (@omarmusayev).</description>
    <link>https://dev.to/omarmusayev</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3931864%2F6a4b7ae1-c60b-4075-9f22-008acb48af16.jpeg</url>
      <title>DEV Community: OmarMusayev</title>
      <link>https://dev.to/omarmusayev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/omarmusayev"/>
    <language>en</language>
    <item>
      <title>I built "Next.js for the terminal" in TypeScript — here's the architecture</title>
      <dc:creator>OmarMusayev</dc:creator>
      <pubDate>Thu, 14 May 2026 19:22:34 +0000</pubDate>
      <link>https://dev.to/omarmusayev/i-built-nextjs-for-the-terminal-in-typescript-heres-the-architecture-53k4</link>
      <guid>https://dev.to/omarmusayev/i-built-nextjs-for-the-terminal-in-typescript-heres-the-architecture-53k4</guid>
      <description>&lt;p&gt;A few months ago I started building &lt;a href="https://terminaltui.dev" rel="noopener noreferrer"&gt;terminaltui&lt;/a&gt; — a TypeScript framework for interactive terminal apps. The pitch is "Next.js for the terminal": write a &lt;code&gt;pages/&lt;/code&gt; directory of TS files, get a fully navigable TUI with file-based routing, components, themes, and SSH hosting.&lt;/p&gt;

&lt;p&gt;It just hit v1.8.1 on npm with 2,142 passing tests. You can try it in zero seconds:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx terminaltui try
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That opens a 5-page guided tour of the framework — no install, no signup.&lt;/p&gt;

&lt;p&gt;This post is the technical writeup: how the file-based router works, the layout engine, and the SSH hosting bit. If you've used &lt;a href="https://github.com/vadimdemedes/ink" rel="noopener noreferrer"&gt;Ink&lt;/a&gt; (React for the terminal), terminaltui is in the same neighborhood but a step further — it ships routing, layout, and themes as &lt;strong&gt;defaults&lt;/strong&gt; instead of "bring your own React patterns."&lt;/p&gt;

&lt;h2&gt;
  
  
  The file-based router
&lt;/h2&gt;

&lt;p&gt;A terminaltui project is just two things: &lt;code&gt;config.ts&lt;/code&gt; and &lt;code&gt;pages/&lt;/code&gt;.&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="c1"&gt;// pages/about.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;card&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;markdown&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;terminaltui&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;metadata&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;About&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;icon&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;◆&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;order&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;About&lt;/span&gt;&lt;span class="p"&gt;()&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;span class="nf"&gt;card&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;About me&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Developer.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}),&lt;/span&gt;
    &lt;span class="nf"&gt;markdown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Some markdown here.&lt;/span&gt;&lt;span class="dl"&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;File paths map to routes the same way Next.js does:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pages/
  index.ts            → /
  about.ts            → /about
  projects/
    index.ts          → /projects
    [slug].ts         → /projects/:slug
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Dynamic routes use bracket syntax. The page function gets &lt;code&gt;{ params: { slug: string } }&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Under the hood, the framework walks the &lt;code&gt;pages/&lt;/code&gt; directory at boot, compiles each TS file via esbuild (or imports directly under &lt;code&gt;tsx&lt;/code&gt; in dev mode), and builds a route table. &lt;strong&gt;Spatial navigation is automatic&lt;/strong&gt; — arrow keys move to the nearest focusable item by screen position. You never write a &lt;code&gt;tabIndex&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can read the &lt;a href="https://github.com/OmarMusayev/terminaltui/tree/main/src/router" rel="noopener noreferrer"&gt;router source on GitHub&lt;/a&gt; if you want to see how the scanner walks the directory and how dynamic segments get parsed.&lt;/p&gt;

&lt;h2&gt;
  
  
  The layout engine
&lt;/h2&gt;

&lt;p&gt;terminaltui has a 12-column grid that behaves like CSS grid + flexbox:&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="nf"&gt;row&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
  &lt;span class="nf"&gt;col&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sidebarBlocks&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;span&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;xs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt; &lt;span class="p"&gt;}),&lt;/span&gt;
  &lt;span class="nf"&gt;col&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;mainBlocks&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;span&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;xs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;12&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="na"&gt;gap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Breakpoints kick in at 60, 90, and 120 terminal columns. Each &lt;code&gt;col&lt;/code&gt; can nest more &lt;code&gt;row&lt;/code&gt;s. The engine measures each block's content (with &lt;code&gt;stringWidth()&lt;/code&gt; for proper CJK/emoji widths), computes a flexbox-like layout, then renders.&lt;/p&gt;

&lt;p&gt;Where this matters: most TUI frameworks make you do absolute positioning or rely on a parent that does. With a grid that wraps responsively, the &lt;strong&gt;same page renders correctly&lt;/strong&gt; in a 200-col Kitty window AND a 60-col Apple Terminal window. (Yes, Apple Terminal gets a 256-color fallback because it can't handle truecolor escapes.)&lt;/p&gt;

&lt;h2&gt;
  
  
  SSH hosting in one command
&lt;/h2&gt;

&lt;p&gt;The thing I'm most happy about: every terminaltui app can be hosted over SSH without touching a single SSH config file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;terminaltui serve &lt;span class="nt"&gt;--port&lt;/span&gt; 2222
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That spins up an SSH server (using &lt;code&gt;ssh2&lt;/code&gt; underneath) that accepts any client, allocates a PTY, and renders the app inside the session. Each connection gets its own isolated runtime — concurrent sessions don't clobber each other's state. The framework auto-detects the client's &lt;code&gt;TERM&lt;/code&gt; and color depth.&lt;/p&gt;

&lt;p&gt;Connect from anywhere with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh user@your-server &lt;span class="nt"&gt;-p&lt;/span&gt; 2222
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means &lt;strong&gt;your CLI doesn't have to be installed&lt;/strong&gt; on the connecting side. You can ship a "live demo" by running &lt;code&gt;serve&lt;/code&gt; once on a VPS — anyone with SSH can experience your app.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/OmarMusayev/terminaltui/blob/main/src/core/ssh-server.ts" rel="noopener noreferrer"&gt;Source for the SSH server&lt;/a&gt; if you want to see how the multi-session isolation works (it uses Node's &lt;code&gt;AsyncLocalStorage&lt;/code&gt; so each session sees its own runtime context).&lt;/p&gt;

&lt;h2&gt;
  
  
  Why TypeScript instead of Go or Rust?
&lt;/h2&gt;

&lt;p&gt;I get this question a lot. Honest answer: most existing TUI frameworks are written in Go (&lt;a href="https://github.com/charmbracelet/bubbletea" rel="noopener noreferrer"&gt;Bubble Tea&lt;/a&gt;), Rust (&lt;a href="https://github.com/ratatui-org/ratatui" rel="noopener noreferrer"&gt;Ratatui&lt;/a&gt;), or Python (&lt;a href="https://github.com/Textualize/textual" rel="noopener noreferrer"&gt;Textual&lt;/a&gt;). Those are great languages but they're all &lt;em&gt;new dependencies&lt;/em&gt; for a JS/TS team. terminaltui ships as a regular npm package — your existing CI/CD, your existing types, your existing editor. No new language, no new build chain.&lt;/p&gt;

&lt;p&gt;Plus: I wanted to write &lt;code&gt;import { card, row, col } from "terminaltui"&lt;/code&gt; and have it Just Work. TypeScript's structural typing + esbuild's speed makes the developer loop feel like React in 2026, not like ncurses in 1990.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's not great yet
&lt;/h2&gt;

&lt;p&gt;Being honest:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Docs are README-only.&lt;/strong&gt; A real docs site is coming. For now the &lt;a href="https://github.com/OmarMusayev/terminaltui" rel="noopener noreferrer"&gt;README&lt;/a&gt; + the bundled demos (&lt;code&gt;npx terminaltui demo restaurant&lt;/code&gt;, etc.) are the manual.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No Windows ConPTY fast path.&lt;/strong&gt; Works on Windows via a fallback, but native ConPTY support would speed it up.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No hot-reload for &lt;code&gt;api/&lt;/code&gt; routes in dev.&lt;/strong&gt; Pages hot-reload fine; API endpoints currently require a restart.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If any of those bother you, the &lt;a href="https://github.com/OmarMusayev/terminaltui/issues" rel="noopener noreferrer"&gt;issues&lt;/a&gt; tab is open.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Tour the framework (no install)&lt;/span&gt;
npx terminaltui try

&lt;span class="c"&gt;# Scaffold a real project&lt;/span&gt;
npx terminaltui init my-site

&lt;span class="c"&gt;# Or run any of the 11 bundled demos&lt;/span&gt;
npx terminaltui demo mac-monitor    &lt;span class="c"&gt;# live macOS activity monitor&lt;/span&gt;
npx terminaltui demo dashboard      &lt;span class="c"&gt;# a portfolio dashboard&lt;/span&gt;
npx terminaltui demo conference     &lt;span class="c"&gt;# a tech conference site&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Source is MIT-licensed on &lt;a href="https://github.com/OmarMusayev/terminaltui" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;. v1.8.1 is &lt;a href="https://www.npmjs.com/package/terminaltui" rel="noopener noreferrer"&gt;on npm&lt;/a&gt;. The landing page lives at &lt;a href="https://terminaltui.dev" rel="noopener noreferrer"&gt;terminaltui.dev&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you build something with it, I'd love to see it.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>terminal</category>
      <category>cli</category>
      <category>framework</category>
    </item>
  </channel>
</rss>
