Skip to main content

SDK usage in a NodeJS context


This guide is intended for use of Juno in a non-interactive environment, not in a browser.


To use Juno in a NodeJS environment, a Fetch API is required for querying satellites.

The most convenient way to achieve this is by using the node-fetch library.

To install node-fetch, run:

npm i node-fetch


In a NodeJS environment, initializing Juno in your app is not required, unlike using Juno in a web application.

The second step in the Install the SDK and initialize Juno guide can be skipped.

Instead, any of Juno's functions can be called with an extra parameter that includes both the fetch library and the satellite ID.

For example, calling the getDoc function from the datastore:

import { getDoc } from "@junobuild/core";
import fetch from "node-fetch";
import { AnonymousIdentity } from "@dfinity/agent";

await getDoc({
collection: "demo",
key: "id2",
satellite: {
identity: new AnonymousIdentity(),
id: "t6rzw-2iaaa-aaaaa-aaama-cai",

Since authentication is not required in this context, information about authentication must also be provided. The DFINITY agent-js library can be used to build an identity.