React is a free, open-source JavaScript library for building user interfaces, created and maintained by Meta. It's the most-used frontend tool in the world, reported in roughly 44.7% of developer surveys. It's built around small, reusable components and a virtual DOM that efficiently updates only what changed, which is why it became the default building block for modern web UIs.
A functional component with the useState hook is the standard way to add local state to a React component.
import { useState } from 'react';
function Counter() {
const [count, setCount] = useState(0);
return (
<div>
<p>You clicked {count} times</p>
<button onClick={() => setCount(count + 1)}>
Click me
</button>
</div>
);
}
export default Counter;
Modern React projects are usually scaffolded with a build tool like Vite rather than a standalone install.
# scaffold a new React project with Vite
npm create vite@latest my-app -- --template react
cd my-app
npm install
npm run dev