HN Reader

NewTopBestAskShowJob
Show HN: Nocterm – Flutter-inspired TUI framework with hot reload (Dart)
score icon3
comment icon1
3 hours agoby norbert515
Over the past couple of months I've been working on a TUI framework heavily inspired by Flutter, written in Dart.

The API is modeled after Flutter. StatefulComponent, setState(), Row, Column, Expanded, ListView.

There have been some discussions about performance of TUIs recently, and I think Dart is actually a great language for writing TUIs in. It compiles down to fast native code, is cross-platform, and has great developer ergonomics. JIT compilation for development (which enables hot reload) and AOT compilation for production binaries.

What's really cool is stateful hot reload. If you save your file with some modification, Nocterm will pick it up and update the TUI in real time without restarting.

Under the hood:

- Differential rendering: virtual terminal buffer, only redraws changed cells - Declarative component model (same as Flutter): Component → Element → RenderObject pipeline - 45+ components: layout, scrolling, text input, markdown, animations, mouse support - Built-in test framework: pump a component, send keys, assert on terminal state - Theming: 6 built-in themes, auto-detects terminal dark/light mode

Example:

void main() async { await runApp(Counter()); }

class Counter extends StatefulComponent { int _count = 0;

  Component build(BuildContext context) {
    return Focusable(
      onKeyEvent: (event) {
        if (event.logicalKey == LogicalKey.space) {
          setState(() => _count++);
          return true;
        }
        return false;
      },
      child: Center(child: Text('Count: $_count')),
    );
  }
}

I tried a couple of existing TUI frameworks but missed the Flutter DX I've learned to love, so I built my own (for better or worse...).

I've been using Nocterm to build vide_cli (https://github.com/Norbert515/vide_cli), a coding agent in the terminal.

There's some cool stuff coming up too, like virtual text selection in alternate screen mode. Since TUI apps take over the terminal, normal text selection breaks. This reimplements it at the framework level so users can select and copy text naturally.

Repository: https://github.com/Norbert515/nocterm

Happy to answer questions about the architecture, hot reload implementation, or anything else.