React
A library for building web interfaces out of reusable LEGO-like pieces whose screen automatically updates whenever data changes.
On this page
What is React?
React is a JavaScript library for building user interfaces. It lets you split a web page into reusable building blocks called components—like buttons, cards, and navigation bars—and automatically refreshes the screen whenever the data inside them changes.
Think of LEGO bricks paired with a digital scoreboard: build one button brick and place it anywhere, and when the score changes from 0 to 1, the scoreboard flips to 1 on its own without you erasing and redrawing it.
With React, you do not redraw the page by hand—you update the data, and React updates the screen for you.
How does React build a page?
From one small button to a busy interactive page, React follows four simple steps.
Split the page into bricks: a top bar is one component, a card is another, and a like button is its own tiny component.
Snap bricks together: nest small components inside bigger ones to form a full page, reusing the same card brick as many times as you need.
Give bricks a memory (state): store changing values—such as how many times a button was clicked—as
state.Refresh only what changed: when a click bumps the count from 3 to 4, React updates just that number instead of rebuilding the whole page.
Updating only the parts that changed keeps pages snappy and keeps your code tidy.
Look at a tiny brick: a like button
This mini component creates a self-contained like button that counts up every time you click it.
LikeButtonis the name of this brick—you can drop it at the bottom of an article or inside every card.useState(0)gives the button a memory calledlikes, starting at0.- Clicking the button calls
setLikes(likes + 1); once the number changes, the label on the button updates automatically.
Do not worry about memorizing every symbol—just notice how storing the count keeps the button text in sync:
import { useState } from 'react';
export function LikeButton() {
const [likes, setLikes] = useState(0);
return (
<button onClick={() => setLikes(likes + 1)}>
Likes: {likes}
</button>
);
}Notice there is no manual step to hunt down the button, erase the old text, and write the new number—you change the number and React handles the screen.
How is React different from updating a page by hand?
For a tiny page, hand-editing works fine; once a page has lots of clicks and changing data, React’s brick approach shines.
| Compare | React | Hand-updating (plain JS) |
|---|---|---|
| Reusing UI pieces | Write a card component once, reuse it everywhere, and edit it in one place | Often requires copy-pasting the same HTML and remembering to update every copy |
| Updating when data changes | Change the data and React figures out which part of the screen to refresh | You manually find each label, badge, and button and rewrite them one by one |
| As pages grow complex | Each piece manages its own job, keeping dozens of interactions organized | Easy to update one spot and forget another, leaving the screen out of sync |
If you only need a short static page, plain HTML is enough. Once you add filters, search, dialogs, or live counters, React makes life much easier.
When is React a good fit?
React shines whenever a page reacts to user clicks or repeats the same layout across many items.
- Interactive screens: chat boxes, shopping carts, filterable lists, and hands-on learning demos.
- Repeated layouts: dozens of tool cards in a directory or product tiles in a store.
- Foundation for full frameworks: powers Next.js and pairs with popular component kits like shadcn/ui and Base UI.
Clear component mental model, huge ecosystem of ready-made parts, and AI coding tools know React inside out.
React only draws the interface—it does not include URL routing or backend APIs, which is why people pair it with a framework like Next.js.
Common things people get wrong
Is React a brand-new programming language?
No. You write React using JavaScript or TypeScript, with a handy HTML-like syntax called JSX for describing what appears on screen.
Does installing React alone give you URLs, APIs, and a database?
No. React focuses on drawing the screen and keeping it in sync with data; routing, server APIs, and storage usually come from tools like Next.js and a database.
Can React only build websites?
Websites are its main home, but the same component and state ideas also power iOS and Android apps through React Native.
Quick quiz
In a React like button, when a click changes the count from 3 to 4, do you manually erase the old text on the button and write 4?
No. You only update the stored count to 4, and React automatically refreshes the button’s label for you.
Remember this: React splits a page into reusable bricks and updates the screen automatically whenever data changes.
Read further
Explore these official React guides next.