0.0.2 • Published 1 year ago

use-node v0.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

use-node

useNode React server hook

This is a hook working with React Server Component (RSC) and Next.js with App Router.

Getting Started

npm install use-node

or

yarn add use-node

or

pnpm add use-node

Usage

import { useNode } from "use-node";
import { ClientComponent } from "./ClientComponent";

export default async function App() {
  const process = await useNode("node:process");
  console.log("env", process.env.NODE_ENV); // server log

  // pass this to the Client Component
  return <ClientComponent data={process.env.NODE_ENV} />;
}

Docs

useNode

const data = await useNode(module: Modules)

Possible modules

type Modules =
  | "node:async_hooks"
  | "node:buffer"
  | "node:child_process"
  | "node:cluster"
  | "node:console"
  | "node:constants"
  | "node:dgram"
  | "node:diagnostics_channel"
  | "node:dns"
  | "node:dns/promises"
  | "node:fs"
  | "node:fs/promises"
  | "node:http"
  | "node:http2"
  | "node:https"
  | "node:inspector"
  | "node:net"
  | "node:os"
  | "node:path"
  | "node:perf_hooks"
  | "node:process"
  | "node:querystring"
  | "node:readline"
  | "node:repl"
  | "node:stream/promises"
  | "node:stream/web"
  | "node:string_decoder"
  | "node:timers"
  | "node:timers/promises"
  | "node:tls"
  | "node:trace_events"
  | "node:tty"
  | "node:url"
  | "node:util"
  | "node:v8"
  | "node:vm"
  | "node:wasi"
  | "node:worker_threads"
  | "node:zlib";
0.0.2

1 year ago

0.0.1

1 year ago