What Is React? Definition and How It Works
React is a JavaScript library for building UIs from reusable parts. What it means, how JSX and the virtual DOM work, and how it pairs with a CMS.

React is a JavaScript library for building user interfaces out of reusable components. That's the short definition. Facebook released it in 2013, and it's now the most widely used UI library in web development. This guide covers what React actually does. Three ideas make it work. It also covers where a headless CMS fits into a React app.
What Does React Actually Do?
React lets you build a UI as a tree of small, reusable pieces called components. Each component owns a piece of the screen and the logic behind it. Instead of writing one long HTML file, you write a Header, a ProductCard, a Footer, and combine them.
The core idea is declarative rendering. You describe what the UI should look like for a given state. React handles updating the actual page when that state changes. You don't write the step-by-step DOM instructions yourself.
React is a library, not a framework. It handles rendering and component state. Routing, data fetching, and build tooling come from other tools, or from a framework like Next.js built on top of it.
What Is JSX?
JSX is a syntax extension that lets you write HTML-like markup directly inside JavaScript. A component's JSX describes what the UI should render, mixed right in with the logic that produces it.
function Greeting({ name }) {
return <h1>Hello, {name}</h1>;
}
That looks like HTML, but it's not. A build tool compiles JSX into plain JavaScript function calls before it reaches the browser. <h1>Hello, {name}</h1> becomes a call that creates a lightweight object describing that element. JSX is convenience for humans. The machine never sees the tags.
Do you have to use JSX?
No. You can write React without it, calling createElement directly. Almost nobody does, because JSX reads far closer to the HTML you're already picturing. It's the default in every React tutorial and nearly every real codebase for that reason.
What Are React Components?
A component is a JavaScript function that returns JSX. That's the whole definition in modern React. You pass data in as props, arguments the component reads but doesn't change, and the component returns the markup for that data.
function ProductCard({ title, price }) {
return (
<div>
<h2>{title}</h2>
<p>${price}</p>
</div>
);
}
Components nest inside each other. A ProductList component renders a ProductCard for each item in an array. That nesting is how a whole application gets built from small pieces, each one easy to test and reuse on its own.
React also has state, data a component tracks and can update over time, separate from props passed in from outside. The useState hook is the standard way to add it to a function component. Change the state, and React re-renders that component with the new value.
What Is the Virtual DOM?
The virtual DOM is a lightweight, in-memory copy of the real webpage structure. React keeps this copy and updates it first, whenever your data changes, instead of touching the real page directly.
Direct DOM updates are slow, especially many of them in a row. React's fix: build a new virtual copy after a change. Compare it to the previous one. Figure out exactly which parts differ. Only those specific differences get applied to the real page. This comparison step is called reconciliation, and the algorithm behind it is often called diffing.
The payoff is real, but the mental model matters more than the speed. You just describe the UI for the current data. React works out what actually needs to change. You never write manual instructions. No "find this element and update its text."
How React Fits Into a Website
A React app usually starts from one root element in an HTML page, then renders the entire UI into it. That's called client-side rendering. It fits a single-page app well but leaves the browser to do more work before a user sees anything.
Frameworks built on React, mainly Next.js, add server-side rendering and static generation on top. The server sends fully rendered HTML on the first load, and React takes over in the browser afterward. That's the shape most production React sites use today. It fixes the empty-page-then-flash problem plain client-side React has on a slow connection.
Either way, React itself only handles the view layer. Data has to come from somewhere. That's where content, whether it's a blog post, a product listing, or a marketing page, usually comes from an API.
Where a Headless CMS Fits Into a React App
A headless CMS stores content and serves it over an API. It has no opinion about how that content renders. That pairs naturally with React, since React already expects data to arrive from somewhere outside the component tree.
A typical pattern: fetch entries from the CMS's delivery API, then pass the result into your components as props.
const res = await fetch('https://api.draftbase.co/delivery/entries?templateId=blogPost', {
headers: { Authorization: `Bearer ${process.env.DRAFTBASE_KEY}` },
});
const { entries } = await res.json();
Each entry becomes props for a BlogPost component, the same way any other data would. Rich text content stored as MDX renders through a component like @draftbase/renderer's MDXContent. It runs as a React Server Component in Next.js's App Router. Plain Markdown can go through react-markdown instead. The content and the component tree stay separate systems. They meet at render time. That's the point of a headless setup. The full breakdown of what a headless CMS is covers that architecture in more depth. Building the editing side too? Start with the best rich text editors for React.
Common React Beginner Mistakes
A few mistakes trip up nearly every new React developer. They're worth naming, since they explain a lot of confusing error messages.
Mutating state directly, instead of calling the setter function, is the most common one. Writing user.name = 'Sam' after useState changes the object in place, but React never finds out, so the screen doesn't update. The fix is always to call the setter with a new object: setUser({ ...user, name: 'Sam' }).
Missing a key prop on a list is the second. Rendering an array of components without a unique key on each one makes React's diffing guess at which item is which. That shows up as items losing their state on reorder, or rendering in the wrong place.
Confusing props with state trips up a lot of people early on too. Props come from a parent and a component never changes them itself. State belongs to the component and changes over its lifetime. Treating a prop like it's mutable state is a bug waiting to surface the first time a parent re-renders.
Conclusion
React is a component-based library for building UIs. It uses JSX to describe markup and a virtual DOM to keep updates fast. None of that includes fetching or storing content. That's where a headless CMS comes in, serving typed data over an API that a React component tree renders.
Draftbase serves that content as plain MDX over a delivery API built for exactly this kind of fetch. Templates become typed content, TypeScript types generate straight from your schema, and @draftbase/renderer ties the MDX to your React component tree. Start on Hobby for free, no card required, on the pricing page.
Ship content that's built to be found
Draftbase generates schema, structured data, and a fast MDX editor for every post.
Frequently asked questions
What is React?
React is a JavaScript library for building user interfaces out of reusable components. Facebook released it in 2013. It's now the most widely used UI library on the web.
What does React mean in coding?
It means building a UI as small, reusable pieces called components. Each one owns a bit of the screen and the logic behind it, instead of one long page of markup.
Is React a language or a framework?
Neither. It's a library. It handles rendering and component state. Routing and data fetching come from other tools, or from a framework like Next.js.
What is JSX in React?
JSX is a syntax that lets you write HTML-like markup inside JavaScript. A build step compiles it into plain JavaScript before the browser ever sees it.
What is the virtual DOM?
A lightweight in-memory copy of the page. React updates this copy first, compares it to the last version, then applies only the real changes. That's faster than updating the page directly every time.