API Reference
txiki.js provides a comprehensive set of APIs for building applications. The global tjs namespace contains core functionality, while additional features are available as importable standard library modules.
Global APIs
The tjs global object provides the following groups of APIs:
- Filesystem — File I/O, directory operations, path manipulation, and file watching.
- Networking — TCP, UDP, and Unix pipe sockets for building network applications.
- HTTP Server — High-performance HTTP server with WebSocket support via
tjs.serve(). - Process — Spawn child processes, handle signals, and manage the current process.
- System — Environment variables, OS information, and runtime metadata.
- Engine — Low-level access to the JavaScript engine: bytecode compilation, serialization, and garbage collection.
- Utilities — Console helpers, error formatting, and interactive prompts.
Standard Library
Additional functionality is available as ES modules that can be imported using the tjs: scheme:
| Module | Description |
|---|---|
tjs:assert | Assertion functions for testing |
tjs:ffi | Foreign Function Interface for calling native libraries |
tjs:getopts | Command-line argument parsing |
tjs:hashing | Cryptographic hash functions |
tjs:ipaddr | IP address parsing and manipulation |
tjs:path | File path utilities (POSIX and Windows) |
tjs:posix-socket | Low-level POSIX socket API |
tjs:sqlite | SQLite3 database |
tjs:uuid | UUID generation and validation |
tjs:wasi | WebAssembly System Interface |
In addition, txiki.js supports many Web Platform APIs such as fetch, WebSocket, setTimeout, TextEncoder, and more.