{"record":{"id":"1aa91a37817557b6","repo":"facebook/react","slug":"the-react-server-cannot-be-used-outside-a-react-se-1aa91a","errorCode":null,"errorMessage":"The React Server cannot be used outside a react-server environment. You must configure Node.js using the `--conditions react-server` flag.","messagePattern":"The React Server cannot be used outside a react-server environment\\. You must configure Node\\.js using the `--conditions react-server` flag\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-server-dom-esm/static.js","lineNumber":10,"sourceCode":"/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\n\nthrow new Error(\n  'The React Server cannot be used outside a react-server environment. ' +\n    'You must configure Node.js using the `--conditions react-server` flag.',\n);\n","sourceCodeStart":1,"sourceCodeEnd":14,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-server-dom-esm/static.js#L1-L14","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nnode server.mjs // imports 'react-server-dom-esm/static' -> throws\n\n// after\nnode --conditions react-server server.mjs","handlingStrategy":"validation","validationCode":"// run before importing any server entry\nconst flags = process.execArgv.concat((process.env.NODE_OPTIONS || '').split(' '));\nconst hasReactServer = flags.some(a => a.includes('react-server'));\nif (!hasReactServer) {\n  throw new Error('Start with --conditions react-server before loading react-server-dom-esm/server');\n}","typeGuard":null,"tryCatchPattern":"try {\n  const staticRenderer = await import('react-server-dom-esm/static');\n} catch (e) {\n  if (/react-server environment/.test(e.message)) {\n    throw new Error('Restart the process with --conditions react-server');\n  }\n  throw e;\n}","preventionTips":["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"],"tags":["react-server","conditions","node","package-exports"],"backgroundTag":"missing-react-server-condition","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}