quickjs-libc.c and is available as part of the qjs executable.
The standard library is not part of the core QuickJS engine. It is provided separately as a C library that can be integrated into applications.
Architecture
The standard library consists of three main modules:qjs:std
Core utilities including file I/O, environment variables, and script evaluation
qjs:os
Operating system functions for process management, signals, timers, and workers
qjs:bjson
Binary JSON serialization using QuickJS internal format
Module Imports
To use the standard library modules, import them using theqjs: protocol:
Global Helpers
When using theqjs executable, several global functions and variables are automatically available without imports. See Global Functions for details.
Platform Support
The standard library supports multiple platforms:- Linux - Full support for all features
- macOS - Full support for all features
- Windows - Full support with some API differences
- WASI - Limited support (no
popen,tmpfile, worker threads)
Error Handling
Most OS-level functions follow consistent error handling patterns:- Return
0on success - Return
-errnoon failure (negative error code) - Use
std.Errorconstants to check specific errors - Use
std.strerror(errno)to get human-readable error messages
Thread Safety
The standard library supports multi-threading throughos.Worker:
- Workers run in separate threads with isolated contexts
- Communication happens via message passing (similar to Web Workers)
SharedArrayBuffercan be shared between workers- Signal handlers can only be set in the main thread
Next Steps
Global Functions
Learn about globally available functions in the qjs executable
Standard Module
Explore file I/O and utility functions