Skip to content

Node.js Deployment

Deploy your React Just app using a Node.js environment.

Installation

Install the Node.js adapter package in your project:

bash
$ npm install @react-just/node
bash
$ pnpm add @react-just/node
bash
$ bun add @react-just/node

Add the plugin in the Vite config file:

vite.config.ts
ts
import node from "@react-just/node";
import react from "react-just/vite";
import { defineConfig } from "vite";

export default defineConfig({
  plugins: [react(), node()],
});

Building the App

Build the app with the vite build command. For convenience, add the following script to your package.json:

package.json
json
{
  "scripts": {
    "build": "vite build"
  }
}

Then build the app with:

bash
$ npm run build
bash
$ pnpm build
bash
$ bun run build

By default, the build will be placed in the dist directory. You can change it with the build.outDir Vite config option:

vite.config.ts
ts
import node from "@react-just/node";
import react from "react-just/vite";
import { defineConfig } from "vite";

export default defineConfig({
  plugins: [react(), node()],
  build: { outDir: "lib" },
});

The static Folder

Static assets are emitted to the static folder in the output directory. These can be served directly (e.g., from object storage like S3 behind a CDN).

Start the Server

Start a server using the react-just-node command.

bash
$ npx react-just-node
bash
$ pnpm react-just-node
bash
$ bun react-just-node

By default, this will:

  • Serve the build in the dist directory.
  • Statically serve the files in the dist/static directory.
  • Listen on port 3000, making your app available at http://localhost:3000.

Add a Script

For convenience, add a start script to your package.json:

package.json
json
{
  "scripts": {
    "start": "react-just-node"
  }
}

Then start your app with:

bash
$ npm run start
bash
$ pnpm start
bash
$ bun start

For details about the adapter and CLI options, see the Node.js adapter reference.

Released under the MIT License.