nx.js

Console

Logging to the Console for text based applications

If your application is purely text-based, you can use the familiar console global to write textual data to the screen of the application in the terminal-like interface that libnx provides.

To draw more intricate graphics, you should use the Canvas API.

Example

console.log('Hello World');

ANSI Escape Codes

Listed below is a (non-exhaustive) list of npm modules known to work well with nx.js when using the Console renderer:

  • kluer - Output colored text with ANSI escape codes
  • sisteransi - ANSI escape sequences for moving the cursor

Limitations

It is worth noting that the terminal interface that libnx provides has dimensions of 80 x 45 characters, supports a limited set of unicode characters, and provides no customization options for the appearance of the text.

If you would like more control over the visual appearance of your application, consider using the @nx.js/terminal package, which provides a more full-featured terminal interface powered by xterm.js.

Cards

On this page