Introduction
Documentation menu
Jering.Javascript.NodeJS lets .NET applications invoke JavaScript that runs in Node.js. It is a replacement for the retired Microsoft.AspNetCore.NodeServices package and targets .NET Standard 2.0 and .NET Framework 4.6.1.
Overview
The library starts a Node.js process and sends invocation requests to it over HTTP. A call can load JavaScript from a file, a string or a stream. Arguments are serialized to JSON and results come back as typed .NET values. The process stays alive between calls, so repeated invocations do not pay the startup cost each time.
Two APIs are available. The dependency injection API registers INodeJSService through services.AddNodeJS(). The static API wraps the same behavior in StaticNodeJSService for applications that do not use a container. Both APIs expose the same invocation model.
What you can call
- An exported function in a JavaScript file on disk.
- A module supplied as a string, which is useful for small scripts and tests.
- A module supplied as a stream, which keeps large scripts out of memory.
- Functions that return a value or call a Node style callback.
Requirements
Node.js must be installed and its executable directory must be on the PATH of the machine that runs the .NET application. The library is supported on Windows and macOS and targets .NET Standard 2.0 and .NET Framework 4.6.1.
Next steps
Start with the Quick Start for a complete example. Read Advanced when you need configuration, concurrency or debugging details.