Full answer
React's job is to describe UI and decide what changed. It does not know what a browser is. That separation lets one library power web pages, phones and other targets.
The react package holds what you use inside components: useState and the other hooks, createContext, memo, lazy, Suspense and the JSX runtime. This code is the same on every platform.
A renderer is the package that turns React's decisions into real output. react-dom is the renderer for browsers. It exposes createRoot from react-dom/client to start an app inside a DOM node, hydrateRoot to attach to server-rendered HTML, createPortal for rendering into another node, flushSync and form hooks such as useFormStatus. Server rendering lives in react-dom/server, with functions like renderToString and renderToPipeableStream.
Other renderers follow the same idea: React Native for mobile views, React Three Fiber for 3D scenes, Ink for terminal interfaces. Your components and hooks are the same. Only the primitive building blocks differ, such as div on the web and View in React Native.
Since React 19, the old ReactDOM.render and hydrate APIs no longer exist. Use createRoot and hydrateRoot. The script in the example renders the same component two ways: as a string with the server renderer, and into a DOM node with the client renderer.
When you install a project from a framework, such as Next.js, you may never call createRoot yourself. The framework does it. The packages still do the same jobs.
import { createRoot } from 'react-dom/client';
import { renderToString } from 'react-dom/server';
function Greeting({ name }) {
return <h1>Hello, {name}</h1>;
}
// Server renderer: JSX to an HTML string.
console.log(renderToString(<Greeting name="Asha" />));
// Client renderer: mount into a real DOM node.
const container = document.getElementById('root');
const root = createRoot(container);
root.render(<Greeting name="Ravi" />);
setTimeout(() => console.log(container.innerHTML), 30);The same Greeting component is rendered to a string and mounted into a DOM node. This was run in jsdom, where a root element with the id root exists. Output of the run: <h1>Hello, <!-- -->Asha</h1> <h1>Hello, Ravi</h1>
Key points
- react is the platform-independent core: components, hooks, elements, context.
- react-dom is the browser renderer: createRoot, hydrateRoot, createPortal and server rendering.
- Other renderers reuse react with different primitives.
- ReactDOM.render and hydrate are removed in React 19. Use createRoot and hydrateRoot.
- Frameworks usually mount the app for you.
Common mistakes
- Calling the old ReactDOM.render or hydrate, which are removed in React 19.
- Importing createRoot from react-dom instead of react-dom/client.
- Saying react-dom is "part of React". It is a separate package that React needs for the web.
- Importing react-dom on the server for client-only code, or the reverse.
Follow-ups
- What does hydrateRoot do differently from createRoot?
- Why would a library list react as a peer dependency?
- Which APIs live in react-dom/server, and which should you choose for streaming?
Tips
- Use the word "renderer". It is the concept the question tests.
- Mention that ReactDOM.render is gone in React 19 to show you know the migration.
- Give a non-web example, such as React Native, to show the separation.