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
ThecreateRequestListener function accepts the following options:
build
The server build to use for rendering. Can be aServerBuild 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:
Stream Utilities
The package also exports utilities for working with Node.js streams:Production Deployment
For production deployments:-
Build your application:
-
Set the
NODE_ENVenvironment variable: - 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.