Skip to main content

Overview

The @react-router/node package provides Node.js platform abstractions for React Router, allowing you to run your application on any Node.js server environment.

Installation

Basic Setup

Create a request listener that handles incoming HTTP requests using Node’s built-in HTTP server.

Configuration Options

The createRequestListener function accepts the following options:

build

The server build to use for rendering. Can be a ServerBuild object or a function that returns one.

getLoadContext

A function that returns the load context to pass to route loaders and actions. This allows you to pass environment/platform-specific values.

mode

The mode to run the server in ("development" or "production").

Session Storage

The @react-router/node package includes file-based session storage:
Use the session storage in your routes:

Stream Utilities

The package also exports utilities for working with Node.js streams:

Production Deployment

For production deployments:
  1. Build your application:
  2. Set the NODE_ENV environment variable:
  3. Configure appropriate environment variables for your hosting platform.

Platform Support

This package works with any Node.js hosting platform including:
  • Traditional VPS (DigitalOcean, Linode, etc.)
  • Platform-as-a-Service (Heroku, Railway, Render)
  • Containerized environments (Docker, Kubernetes)
  • Serverless Node.js runtimes
For Express.js integration, see the Express deployment guide.