About njs

What is currently supported
What is not supported yet
Change Log
njs API Reference
Download and install
     Installing as a Linux package
     Building from the sources
Command-line interface

njs is a subset of the JavaScript language that allows implementing location and variable handlers in http and stream. njs is created in compliance with ECMAScript 5.1 with some ECMAScript 6 extensions. The compliance is still evolving.

What is currently supported

What is not supported yet

Change Log

The complete list of njs changes is available here.

njs API Reference

njs API reference is available here.

Download and install

njs is available in two modules:

Both modules are not built by default, they should be either compiled from the sources or installed as a Linux package. In addition, the Linux package provides njs command-line utility.

Installing as a Linux package

For Linux, njs modules packages can be used:

Building from the sources

The repository with njs sources can be cloned with the following command: (requires Mercurial client):

hg clone http://hg.nginx.org/njs

Then the modules should be compiled using the --add-module configuration parameter:

./configure --add-module=path-to-njs/nginx

The modules can also be built as dynamic:

./configure --add-dynamic-module=path-to-njs/nginx

To build only njs command-line utility, run ./configure and make njs commands from njs root directory. The utility is available as ./build/njs.

Command-line interface

njs scripts development and debugging can be performed from the command-line. The command-line utility is available after the installation of the Linux package or after building from the sources. Compared to njs running inside nginx, nginx objects (HTTP and Stream) are not available in the utility.

$ echo "2**3" | njs -
8

$ njs
>> var o = {a:[]}
undefined

>> JSON.stringify(o, undefined,1)
{
 "a": [

 ]
}
>>