facebook/react
Getting started
This page covers the runtime monorepo (everything outside compiler/). For the React Compiler, see compiler/index — it has its own setup steps.
Prerequisites
- Node.js — the version pinned in
.nvmrc. Usenvm useif you have nvm installed. - Yarn 1 (Classic). The repo uses
yarn@1.22.22, declared inpackage.json'spackageManagerfield. - Roughly 5–10 GB of disk for
node_modulesplus build artifacts after a fullyarn build.
The repo does not support npm or Yarn 2/3/4 for top-level workspace operations. The compiler/ workspace happens to use a slightly different toolchain but is also Yarn 1.
Cloning and installing
git clone https://github.com/facebook/react.git
cd react
yarn installyarn install runs the postinstall script node ./scripts/flow/createFlowConfigs.js, which materializes Flow configs for each renderer (the runtime is type-checked with Flow, the compiler with TypeScript).
Building
# Build every package, every channel, every bundle type. Slow (minutes).
yarn build
# Build a focused subset. Useful when iterating on a specific package.
yarn build react/index,react-dom/index,react-dom/client,scheduler --type=NODE_DEV
# Build for the React DevTools extension (also experimental channel).
yarn build-for-devtools-devOutput lands in build/ and is sub-divided by release channel (e.g. build/oss-stable/react, build/oss-experimental/react, build/facebook-www/). The full taxonomy lives in scripts/rollup/build.js.
Running tests
The test command always goes through the bespoke runner in scripts/jest/jest-cli.js, which sets up release-channel and feature-flag environment variables before delegating to Jest:
# Default: the "experimental" channel — most internal tests.
yarn test
# Stable channel only.
yarn test-stable
# Facebook www modern / classic channels.
yarn test-www
yarn test-classic
# Run tests against the built bundles instead of the source.
yarn test --build
# Run a single test file.
yarn test packages/react-reconciler/src/__tests__/ReactHooks-test.js
# Watch mode and pattern matching are supported.
yarn test -t "useState"yarn test is what CI runs, parameterized across channels in .github/workflows/runtime_build_and_test.yml. There is no npm test.
Lint, types, format
# ESLint over the whole repo. The config is .eslintrc.js + custom rules in scripts/eslint-rules/.
yarn lint
# Run only against changed files (used as a pre-push gate).
yarn linc
# Flow type check for the runtime. (Compiler uses TypeScript; see compiler/CLAUDE.md.)
yarn flow
# Prettier — write changed files only.
yarn prettier
# Prettier — rewrite everything.
yarn prettier-allManual smoke-testing fixtures
fixtures/ contains standalone, runnable React apps that the team uses to verify each renderer end-to-end. Notable ones:
fixtures/dom/— the all-in-one DOM playground; pulls a fresh build frombuild/.fixtures/legacy-jsx-runtimes/— verifies JSX runtime behavior across Babel versions.fixtures/flight/— RSC integration test apps (webpack, parcel, turbopack, esm, unbundled).fixtures/devtools/— a fixture used by the DevTools E2E tests.
Each fixture has its own package.json and is installed/built separately.
Recommended IDE setup
The repo ships a VS Code workspace at react.code-workspace. It opens both the runtime and the compiler workspaces side-by-side. Recommended extensions: ESLint, Flow Language Support, Prettier, GitLens.
What to read next
- For an architectural map of where code lives, see overview/architecture.
- For per-package introductions, see packages/index.
- For workflow conventions (branching, labels, the PR template), see how-to-contribute/development-workflow.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.
Previous
Architecture
Next
Glossary