facebook/react · error · Error
The React Server cannot be used outside a react-server envir
Error message
The React Server cannot be used outside a react-server environment. You must configure Node.js using the `--conditions react-server` flag.
What it means
This file is the fallback target of the package's './static' export. The exports map only selects the real static renderer when Node resolves with the react-server condition; without it you get this module, which throws immediately so a server entry never runs in a plain Node process. It enforces that server-side Flight code executes under --conditions react-server.
Source
Thrown at packages/react-server-dom-esm/static.js:10
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
throw new Error(
'The React Server cannot be used outside a react-server environment. ' +
'You must configure Node.js using the `--conditions react-server` flag.',
);
View on GitHub (pinned to eafeac097b)
Solutions
- Start Node with --conditions react-server (node --conditions react-server server.mjs) or set it via NODE_OPTIONS
- Import the explicit variant entry such as 'react-server-dom-esm/static.node', which bypasses the condition gate
- For bundlers: include react-server in conditionNames only for the server build and never for the client build
Example fix
// before node server.mjs // imports 'react-server-dom-esm/static' -> throws // after node --conditions react-server server.mjs
Defensive patterns
Strategy: validation
Validate before calling
// run before importing any server entry
const flags = process.execArgv.concat((process.env.NODE_OPTIONS || '').split(' '));
const hasReactServer = flags.some(a => a.includes('react-server'));
if (!hasReactServer) {
throw new Error('Start with --conditions react-server before loading react-server-dom-esm/server');
} Try / catch
try {
const staticRenderer = await import('react-server-dom-esm/static');
} catch (e) {
if (/react-server environment/.test(e.message)) {
throw new Error('Restart the process with --conditions react-server');
}
throw e;
} Prevention
- Put --conditions react-server in the start script and NODE_OPTIONS of every server environment
- Exclude react-server from browser bundler conditionNames
- Add a boot-time flag check (validationCode) so misconfiguration fails loudly at startup
When it happens
Trigger: Importing 'react-server-dom-esm/static' or './server' in a Node process started without --conditions react-server; a bundler resolving the exports map without react-server in conditionNames; deep-importing the static.js file directly instead of through the exports map.
Common situations: Forgetting the flag in dev scripts, tests, or process-manager configs; bundlers (webpack/vite) resolving the server entry into a browser build; version upgrades where the exports map gained the condition gates.
Related errors
- The React Server Writer cannot be used outside a react-serve
- The React Server Writer cannot be used outside a react-serve
- The React Server cannot be used outside a react-server envir
- The React Server cannot be used outside a react-server envir
- The React Server Writer cannot be used outside a react-serve
AI-assisted analysis of facebook/react@eafeac097b (2026-08-21).
Data as JSON: /api/errors/1aa91a37817557b6.
Report an issue: GitHub.