> ## Documentation Index
> Fetch the complete documentation index at: https://nexus.whatsgood.dog/llms.txt
> Use this file to discover all available pages before exploring further.

# Node.js

> Learn how to use Nexus with Node.js

## Setup

<CodeGroup>
  ```typescript index.ts theme={null}
  import { Nexus, NodeProvider, CHAIN } from "@whatsgood/nexus";
  import { createServer } from "node:http";

  // Step 1: Initialize node providers
  const llamaRpcNodeProvider = new NodeProvider({
    name: "llama-rpc",
    chain: CHAIN.ETHEREUM_MAINNET,
    url: "https://eth.llamarpc.com",
  });

  const tenderlyNodeProvider = new NodeProvider({
    name: "tenderly",
    chain: CHAIN.ETHEREUM_MAINNET,
    url: "https://gateway.tenderly.co/public/mainnet",
  });

  // Step 2: Create a Nexus instance by putting it all together
  const nexus = Nexus.create({
    nodeProviders: [llamaRpcNodeProvider, tenderlyNodeProvider],
    log: { level: "debug" },
    port: 4000,
    relay: {
      order: "random",
    },
  });

  // Step 3: Optionally define event handlers
  nexus.on("rpcResponseSuccess", (response, ctx) => {
    nexus.logger.debug(
      {
        response: response.body(),
        chain: ctx.chain,
      },
      "rpc response success event captured"
    );
  });

  // Step 4: Start the server
  createServer(nexus).listen(nexus.port, () => {
    console.log(`🚀 Server ready at http://localhost:${nexus.port}`);
  });
  ```
</CodeGroup>

## Usage

<Snippet file="send-a-request-no-auth.mdx" />
