Home / Function/ prerenderApp() — react Function Reference

prerenderApp() — react Function Reference

Architecture documentation for the prerenderApp() function in region.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  f79d3aea_e7a2_fb04_8f5d_253a0f73eaf1["prerenderApp()"]
  b3216559_a4bc_a4c6_4246_6887719cfe26["region.js"]
  f79d3aea_e7a2_fb04_8f5d_253a0f73eaf1 -->|defined in| b3216559_a4bc_a4c6_4246_6887719cfe26
  style f79d3aea_e7a2_fb04_8f5d_253a0f73eaf1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

fixtures/flight/server/region.js lines 136–191

async function prerenderApp(res, returnValue, formState, noCache) {
  const {prerenderToNodeStream} = await import(
    'react-server-dom-unbundled/static'
  );
  // const m = require('../src/App.js');
  const m = await import('../src/App.js');

  let moduleMap;
  let mainCSSChunks;
  if (process.env.NODE_ENV === 'development') {
    // Read the module map from the HMR server in development.
    moduleMap = await (
      await fetch('http://localhost:3000/react-client-manifest.json')
    ).json();
    mainCSSChunks = (
      await (
        await fetch('http://localhost:3000/entrypoint-manifest.json')
      ).json()
    ).main.css;
  } else {
    // Read the module map from the static build in production.
    moduleMap = JSON.parse(
      await readFile(
        path.resolve(__dirname, `../build/react-client-manifest.json`),
        'utf8'
      )
    );
    mainCSSChunks = JSON.parse(
      await readFile(
        path.resolve(__dirname, `../build/entrypoint-manifest.json`),
        'utf8'
      )
    ).main.css;
  }
  const App = m.default.default || m.default;
  const root = React.createElement(
    React.Fragment,
    null,
    // Prepend the App's tree with stylesheets required for this entrypoint.
    mainCSSChunks.map(filename =>
      React.createElement('link', {
        rel: 'stylesheet',
        href: filename,
        precedence: 'default',
        key: filename,
      })
    ),
    React.createElement(App, {prerender: true, noCache})
  );
  // For client-invoked server actions we refresh the tree and return a return value.
  const payload = {root, returnValue, formState};
  const {prelude} = await prerenderToNodeStream(payload, moduleMap, {
    filterStackFrame,
  });
  prelude.pipe(res);
}

Domain

Subdomains

Frequently Asked Questions

What does prerenderApp() do?
prerenderApp() is a function in the react codebase, defined in fixtures/flight/server/region.js.
Where is prerenderApp() defined?
prerenderApp() is defined in fixtures/flight/server/region.js at line 136.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free