reactreact-domreact-dom-bindingsreact-reconcilerschedulersharedfacebook/react

React · Dive 01 of 14

The repo itself

The town hall, floor by floor

Before reading a line of React, learn the building it lives in. The repo is a reconciler with a pluggable back end: one package defines the words, one decides when work happens, another touches the screen. The build draws the walls between them, not an interface, so knowing the layout tells you which file to open.

12 scenes · ←/→ to move
packages/41 packages · the runtimecompiler/9 · TS + Rustno road

React 01 · 1 of 13

Two buildings across one street

The repository at github.com/facebook/react is the town hall, and it is really two buildings. The big one is packages/: 41 packages holding the runtime, the renderers, DevTools and the kit React tests itself with. Everything you install as react or react-dom is built from here.

Across the street stands compiler/, a second workspace with nine packages of its own, written in TypeScript and Rust. That is the React Compiler. It runs while your app is being built and never in the browser, so there is no road between it and the runtime: nothing in packages/ imports it.

Three sheds complete the lot. scripts/ holds the build itself (Rollup configs, Flow configs, Jest setup), fixtures/ holds small apps for testing by hand, and flow-typed/ holds type declarations for other people’s code.

The ideaThe compiler is a build-time tool with no runtime link

From the source
The top of the repo
react/
├── packages/     # 41 packages: runtime, renderers, devtools, test infra
├── compiler/     # a SECOND workspace: 9 packages, TypeScript + Rust
├── scripts/      # the build: Rollup config, forks, Flow configs, Jest setup
├── fixtures/     # manual test apps
└── flow-typed/   # third-party type declarations
react-dom-bindings is one of them41 packages · 19 private · never on npm

React 01 · 2 of 13

19 of the 41 doors are locked

Walk the corridor of packages/ and 19 doors are locked. Those packages are private: they never reach npm, so you cannot install them, and they promise no API to anyone. (The census has one oddity: 18 of them say "private": true and react-devtools-fusebox says the string "true".)

Some of the most important code in React sits behind those doors. react-dom-bindings holds the entire DOM implementation. shared holds the symbols and feature flags every layer uses. react-server and react-client hold the two halves of streaming.

They still reach your app. At build time a private package’s code is inlined, copied, into each published bundle that imports it. So when you install react-dom, the DOM code from react-dom-bindings arrives inside it, without its name.

The ideaPrivate packages ship inside the public ones

Check yourselfYou run npm install react-dom-bindings to read the DOM code. What happens?
From the source
The 41 packages, by what they are for
GroupCountExamples
Core runtime6react, react-dom, react-dom-bindings, react-reconciler, scheduler, shared
Server & streaming9react-server, react-client, six react-server-dom-*, react-flight-server-fb
Developer tooling4react-is, react-refresh, use-sync-external-store, eslint-plugin-react-hooks
DevTools10react-devtools, -core, -shared, -extensions, -inline, …
Alternate renderers5react-native-renderer, react-art, react-noop-renderer, react-test-renderer, react-markup
Test infrastructure4internal-test-utils, jest-react, dom-event-testing-library, react-suspense-test-utils
Legacy3react-cache, use-subscription, react-debug-tools
ReactFiber.js · // @flowfunction FiberNode( this: $FlowFixMe, tag: WorkTag, pendingProps: mixed, key: ReactKey, mode: TypeOfMode,) { … }npm: the same code, no types

React 01 · 3 of 13

Written in Flow, shipped without it

Open any runtime file and it looks like TypeScript, yet the name ends in .js. The annotations are Flow, Meta’s own type checker. Of the 1,872 .js files under packages/, 1,124 start with a @flow comment, and only 21 files there are TypeScript.

Like scaffolding taken down before the opening, the types are stripped at build time and none of them reach npm. Every type this dive names, Fiber, WorkTag, Flags, Lanes, is a Flow type you will only ever see in the repo.

The runtime stays on Flow because Flow is Meta’s tool and the code leans on features like exact and opaque object types. The newer tooling, the compiler and eslint-plugin-react-hooks, is TypeScript.

One consequence reaches your editor. Neither react nor react-dom ships type definitions. @types/react is a translation written by hand on DefinitelyTyped, maintained separately, so it can lag behind a release or now and then disagree with React.

The ideaThe types are scaffolding: none of them reach npm

From the source
Flow syntax, in a .js file: the start of the fiber constructorReactFiber.js:134–140 ↗
function FiberNode(
  this: $FlowFixMe,          // ← Flow syntax, in a .js file
  tag: WorkTag,
  pendingProps: mixed,
  key: ReactKey,
  mode: TypeOfMode,
) { … }
What the files are written in
WhereCount
.js files under packages/1,872
…with a @flow pragma1,124
.ts files under packages/21
Under compiler/: .ts / .tsx / .rs393 / 114 / 120
DEVDEVDEVsourceif (__DEV__) { … }buildproduction__DEV__ → false → gone

React 01 · 4 of 13

Pages torn out before printing

The source does not run as written. Three build-time tricks stand between these files and anything your browser executes, and the first is __DEV__.

It looks like a global variable, but no such variable exists. The build (scripts/rollup/build.js) replaces every __DEV__ with the literal true or false, and the minifier then deletes the branch that can never run. In production, development code is not skipped: it is missing from the bundle altogether.

That is why a file can be half warnings and cost nothing in production. The missing-key warning, frozen props, component stacks: all of it sits inside if (__DEV__) blocks that are torn out of the production copy.

The second trick is the imports. import … from 'shared/ReactSymbols' names a package that is in no node_modules anywhere. shared is a workspace name, and Rollup (for builds) and Jest (for tests) resolve it to packages/shared/.

The ideaDevelopment code is deleted from production, not skipped

From the source
What __DEV__ turns intoOur example, not from the source
// in the source
if (__DEV__) {
  console.error('Each child in a list should have a unique "key" prop.');
}

// the development bundle: __DEV__ became true,
// so the warning stays

// the production bundle: __DEV__ became false, and
// the branch that can never run was deleted. Nothing is left.
Imports that name workspace packages, not installed onesOur example, not from the source
import {REACT_ELEMENT_TYPE} from 'shared/ReactSymbols';
import {Fiber} from 'react-reconciler/src/ReactInternalTypes';
// both resolve to packages/<name>/ through Rollup and Jest aliases
ReactFeatureFlags.jsthe defaultshared/forks/: .www.js, .native-fb.js,.native-oss.js, .test-renderer.js, …

React 01 · 5 of 13

The file you read may not be the one you ship

The third trick is forks/. Seven places in the repo have a directory with that name: shared, scheduler, react-reconciler, react-client, react-server, use-sync-external-store and react-dom-bindings/src/events. Each one holds alternative versions of one module, and the build swaps one of them in.

The clearest case is shared/forks/, with ten variants of ReactFeatureFlags.js: .www.js, .native-fb.js, .native-oss.js, .test-renderer.js and more. This is where Meta’s internal build parts ways with the npm one, so a flag’s value in the default file is not necessarily its value in the bundle you installed.

Put the three tricks together and you have the rule for this whole dive: read this repo, do not try to run it, and do not expect node_modules/react to look like it. What you install is Rollup’s output, with the flags resolved, the forks chosen and everything minified.

The ideaRead the repo; do not expect node_modules to match it

Check yourselfA feature flag reads true in ReactFeatureFlags.js, but the feature is missing from your npm build. Where do you look?
reactthe wordsreact-domthe front doorreact-dom-bindingsthe DOM workreact-reconcilerthe planningschedulerthe clocksharedthe plumbing

React 01 · 6 of 13

Five floors and a foundation

Now the shape. React is five layers stacked like floors, with one more running underneath them all. Each floor runs on the one below it, and each one deliberately ignores something.

At the top is react, the words: hooks, createContext, the JSX runtime. It has no dependencies and cannot render anything. Below it is the renderer you import, react-dom (or react-native-renderer, or react-art), which gives you createRoot, hydrateRoot and the server entry points, and is mostly a thin front.

Then the private react-dom-bindings, where the DOM work really happens: nodes, attributes, events. Below that, react-reconciler: fibers, hooks, lanes, the work loop and the commit, and not one line about the DOM. At the bottom, scheduler, a queue of tasks with priorities that knows nothing about React at all.

Under every floor runs shared, the plumbing: symbols, feature flags and small utilities that every layer imports. Even these are careful. Helpers like isArray and hasOwnProperty capture the built-ins once, rather than trusting a global someone may have patched.

The ideaEach floor runs on the one below and ignores the rest

From the source
The core packages, one at a time
PackageStatusSize (non-test)What it is
react19.3.030 files · ≈4,000 linesHooks, createContext, memo, lazy, the JSX runtime. Zero dependencies.
react-dom19.3.0≈4,600 linesEntry points only: ./client, ./server.*, ./static.*, ./profiling, ./test-utils.
react-dom-bindingsprivate93 files · 31,340 linesThe host config, DOM properties, controlled inputs, the synthetic event system, the server DOM config.
react-reconciler0.34.0≈50,800 linesFiber, the work loop, begin/complete/commit, hooks, lanes, child reconciliation.
scheduler0.28.011 files · ≈2,000 linesA min-heap task queue with five priority levels. Four implementations: browser, mock, native, postTask.
sharedprivate48 files · ≈3,900 linesSymbols, feature flags, error formatting, small helpers that capture built-ins once.
react-dom-bindingsreact-reconcilerReactFiberConfig.js · throws.dom.fabric.art.test.noop.markup.custom

React 01 · 7 of 13

A socket between two floors

The most important line in the building runs between react-dom-bindings and react-reconciler. One reconciler drives the DOM, React Native, a canvas and a test renderer, so it cannot import DOM code. Instead it imports a module called ReactFiberConfig: the host config.

Open that file and it holds one statement, and the statement throws. It is an empty socket. At build time Rollup, Jest and Flow each plug in one of seven forks: .dom, .fabric (React Native), .art, .test, .noop, .markup or .custom. The DOM plug is two lines that re-export the real config from react-dom-bindings.

So there is no HostConfig interface anywhere in the repo. The contract is simply the list of names the reconciler imports. A renderer that lacks a capability says so by re-exporting one of nine ReactFiberConfigWithNo* files, like WithNoHydration. The DOM uses WithNoPersistence.

Renderers outside the repo get the .custom plug. The npm build of react-reconciler is wrapped in module.exports = function ($$$config) { … }, and that fork reads each host method off the object you pass in. That is why the public API is a factory, Reconciler(hostConfig), while inside the repo the host config is just an import.

The ideaThe seam is a module swap, not an interface

Check yourselfWhy is there no HostConfig interface type in the repo?
From the source
The socket: the whole runtime content of the moduleReactFiberConfig.js ↗
throw new Error('This module must be shimmed by a specific renderer.');
The DOM plug: the entire fileReactFiberConfig.dom.js ↗
export * from 'react-dom-bindings/src/client/ReactFiberConfigDOM';
export * from 'react-client/src/ReactClientConsoleConfigBrowser';
react-dom≈4,600 non-test lines · entry pointsreact-dom-bindings31,340 lines · the real DOM workpropertieseventshost configto scale

React 01 · 8 of 13

react-dom is mostly an empty lobby

Here is the surprise most readers hit first. The package everyone imports, react-dom, contains almost no DOM code. Its src/ holds 186 files and about 123,000 lines, yet only about 4,600 of those lines are not tests: the entry points, and little else.

The real work happens behind the lobby, in the private react-dom-bindings: 93 files, 31,340 lines, and no tests of its own. Every DOM property write, the synthetic event system and the DOM host config live there. Its tests live in react-dom/src/__tests__, which is why react-dom/src/events/ contains only test folders.

That gives you a rule for finding things. What can I import? react-dom. What does React do to the DOM? react-dom-bindings. When does it do it? react-reconciler.

The ideaWhat happens: the bindings. When: the reconciler.

Check yourselfYou want to find where React sets a DOM attribute. Which package do you open?
From the source
The lobby and the workshop
PackageFiles in src/Total linesNon-test lines
react-dom186≈123,000≈4,600
react-dom-bindings9331,34031,340 (no tests)
react-serverFizz → HTML<ul><li><li>Flight → wire formatreact-clientreact-server-dom-* plugs in the bundler

React 01 · 9 of 13

Two halves of streaming

Two more locked rooms matter later. react-server holds two renderers whose codenames you will meet in file names everywhere. Fizz (ReactFizzServer.js) turns a React tree into a stream of HTML: that is server-side rendering. Flight (ReactFlightServer.js) turns a tree of Server Components into a wire format that is not HTML at all.

react-client is the other half. ReactFlightClient.js reads the Flight stream back into a tree, and ReactFlightReplyClient.js sends Server Action arguments the other way.

Neither knows about the DOM or about any bundler. Like the reconciler, each imports a config module that the build swaps in. The six react-server-dom-* packages supply what is missing: the DOM target, and how a "use client" import becomes an id the browser can resolve.

This is the concrete reason Server Components need a framework. Someone has to own the bundler integration, and react-server-dom-webpack says outright that it is meant for meta-frameworks, not to be imported directly.

The ideaServer Components need whoever owns the bundler

From the source
The six bindings for streaming, one per bundler
PackageBundlerNote
react-server-dom-webpackwebpackShips a plugin, a Node loader and a register hook
react-server-dom-turbopackTurbopackTurbopack integrates on its own side
react-server-dom-parcelParcelParcel supplies the integration
react-server-dom-esmnative ESMNode and browser only
react-server-dom-unbundlednonePrivate, for internal testing
react-server-dom-fbMeta-internalPrivate
app devs19.3.0reactlibrarystablereact-isrenderers0.34.0react-reconcilerstaff onlyprivate

React 01 · 10 of 13

A door for every visitor

Each package is built for a different visitor, and its version number tells you how much it promises.

react and react-dom are for app developers: semver applies, and breaking changes come with migration guides. react-is and use-sync-external-store are for library authors, small and stable with wide peer ranges. react-refresh, two files behind Fast Refresh, is for bundler-plugin authors; you meet it through Vite or Next.

react-reconciler is for people writing renderers, and it is 0.34.0 while react-dom is 19.3.0, built from the same commit. The 0. is the promise: the host-config API may change in any release, and its README calls it experimental. scheduler is published too, but its README says the public API is not final.

Behind the staff-only doors, the private packages promise nothing and are reorganised freely. If a file moved between versions, check whether it lives in one. And one door hides in plain sight: react ships two builds. Its exports map has a "react-server" condition that picks a build with the client-only hooks removed, and your bundler chooses.

The ideaThe version number is the promise

From the source
Who each package is for
PackageAudienceWhat that implies
react, react-domApp developersSemver applies. Breaking changes come with migration guides.
react-is, use-sync-external-storeLibrary authorsSmall, stable, wide peer ranges.
eslint-plugin-react-hooksApp developersA devDependency with its own version line.
react-reconcilerRenderer authorsPublished but 0.x. The host config changes between releases.
react-refreshBundler-plugin authorsYou use it through a plugin.
react-server-dom-*Framework authorsNot meant to be imported directly.
schedulerInternal, in practicePublished, but its README says the public API is not final.
react-dom-bindings, shared, react-server, react-clientInternalPrivate. No API, no compatibility promise.
16.02017Fiber16.82019Hooks17.02020Boundaries18.02022Concurrent19.02024Servercompiler

React 01 · 11 of 13

Five renovations

The building did not always look like this. Five releases, dated from the repo’s CHANGELOG.md, explain most of its layout.

  1. 16.0, September 2017. Fiber. The reconciler went from a recursive walk to an interruptible loop over a linked list. Moving the traversal from the call stack into data is what let “what to do”, “when to do it” and “how to touch the host” become separate floors.
  2. 16.8, February 2019. Hooks: state for function components, kept as a linked list on the fiber. The rules of hooks are checked by a linter, not by types, so eslint-plugin-react-hooks was created.
  3. 17.0, October 2020. No new features. The new JSX transform added react/jsx-runtime, and events moved from document to the root container, so two versions of React can share a page.
  4. 18.0, March 2022. Concurrent rendering: createRoot, startTransition, useSyncExternalStore. react-dom grew ./client, and the server entry split per runtime.
  5. 19.0, December 2024. Server Components and Actions. React stopped being one runtime: nine packages exist because of the client/server split.

The ideaFiber is what made the floors possible

From the source
What each release did to the packages
ReleaseWhat changedWhat it did to the packages
16.0 · 26 Sep 2017FiberTraversal state moved from the call stack into data, which allows the separate layers.
16.8 · 6 Feb 2019HooksReactFiberHooks.js became one of the largest reconciler files; eslint-plugin-react-hooks was created.
17.0 · 20 Oct 2020Gradual upgradesreact gained ./jsx-runtime and ./jsx-dev-runtime. Root-level events let two versions share a page.
18.0 · 29 Mar 2022Concurrent renderingreact-dom grew ./client; use-sync-external-store was published so libraries could adopt it early.
19.0 · 5 Dec 2024Server Componentsreact-server, react-client, six react-server-dom-* and react-flight-server-fb; react ships a "react-server" build.
12345678scripts/

React 01 · 12 of 13

How to walk the building

You now know which floor each question lives on. When you open the repo yourself, this order works, from the smallest and most self-contained files to the spine:

  1. packages/*/package.json, all 41: which are private, what depends on what, how many entry points each one has.
  2. packages/react/src/: small and dependency-free. Start at the JSX runtime, which is Dive 03.
  3. react-reconciler/src/ReactInternalTypes.js: the commented Fiber type, which is Dive 04.
  4. react-reconciler/src/ReactFiberConfig.js and one fork: the seam. After this the reconciler stops looking DOM-shaped.
  5. scheduler/src/: about 2,000 lines and self-contained.
  6. react-reconciler/src/ReactFiberWorkLoop.js: the spine. Everything in the reconciler is called from it.
  7. react-dom-bindings/src/client/ReactFiberConfigDOM.js: the other side of the seam.
  8. scripts/rollup/forks.js and scripts/shared/inlinedHostConfigs.js, only when a module resolution confuses you.

The ideaSmall and self-contained first, then the spine

From the source
Two habits that help everywhereOur example, not from the source
# the implementation is opaque? read what it is tested against
ls packages/react-reconciler/src/__tests__/

# when did a feature arrive? the changelog knows
grep -n "useSyncExternalStore" CHANGELOG.md
reactreact-domreact-dom-bindingsreact-reconcilerschedulersharedfacebook/react

React 01 · 13 of 13

What to keep

  • 41 packages, 19 of them private. The DOM implementation, shared and both halves of streaming are in packages you cannot install.
  • Flow-typed JavaScript, not TypeScript. TypeScript is only in the compiler and the ESLint plugin, and React ships no type definitions.
  • Three tricks make the source unrunnable as written: __DEV__ as a literal the build writes in, workspace-aliased imports, and forks/.
  • Five floors: react → the renderer’s entry points → the host bindings → the reconciler → the scheduler, with shared under them all.
  • react-dom has almost no DOM code. It lives in the private react-dom-bindings.
  • The host config is a build-time swap with no interface type: seven forks fill in one module that only throws.
  • Fiber (2017) made the layers possible, hooks (2019) changed what a fiber stores, 17 fixed the boundaries, 18 shipped concurrency, 19 split React into client and server.

Read from facebook/react at dcd4ec28a1 (react 19.3.0, 26 July 2026). Line numbers are from that commit.

Dive 02: The rest of the packages ↓