Web Development with React
ConceptBeginner 15 min· Web foundations · 1 of 21

How the web works

Follow one click from the address bar to a finished page: URLs, DNS, HTTP requests and responses, and how the browser turns HTML, CSS and JavaScript into what you see. This is the mental model every React developer works on top of.

Every time you open a website, two programs talk to each other. Your browser (the client) asks for something, and a server (a computer somewhere else) answers. Everything in web development, React included, sits on top of this simple conversation.

Think of ordering at a coffee shop counter. You (the browser) say exactly what you want, the barista (the server) prepares it and hands it over with a receipt. If you ask for something that isn't on the menu, you get a polite "we don't have that". The web works the same way, with very precise rules for how to ask and answer.

Step 1: the URL says what you want

A URL (Uniform Resource Locator) is the full address of one thing on the web. Take https://brewandbean.example/menu?category=coffee. It has four parts you should recognise on sight.

Parts of a URL

PartExampleMeaning
SchemehttpsHow to talk: HTTP with encryption (TLS)
Host (domain)brewandbean.exampleWhich server to ask
Path/menuWhich page or resource on that server
Query string?category=coffeeExtra options, as key=value pairs

There can also be a port (:5173 in http://localhost:5173, which you will see when you run React locally) and a fragment (#reviews), which the browser uses to jump to a section and never sends to the server.

Step 2: DNS finds the server

Computers find each other by IP address (for example 142.250.183.4), not by name. DNS (Domain Name System) is the internet's phone book: the browser asks a DNS resolver "what is the IP address of brewandbean.example?" and gets an address back. Answers are cached by your browser, your operating system and your internet provider, so the second visit is faster.

With the IP address in hand, the browser opens a connection to the server. For https it also performs a TLS handshake, which sets up encryption so nobody on the café Wi-Fi can read or change the traffic.

Terminal
nslookup example.com

Asks DNS for the IP address of a domain. Works on Windows, macOS and Linux. The addresses you see may differ from someone else's.

Step 3: an HTTP request and response

Over that connection the browser sends an HTTP request: a method (what to do), a path (what to do it to), headers (extra information) and sometimes a body (data). The server replies with an HTTP response: a status code (how it went), headers and a body (the actual content: HTML, CSS, JavaScript, an image or JSON).

A simplified request and response
GET /menu HTTP/1.1
Host: brewandbean.example
Accept: text/html

--- response ---

HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8

<!doctype html>
<html>
  <head><title>Brew & Bean menu</title></head>
  <body>...</body>
</html>

Real requests carry more headers (cookies, browser name, accepted languages). Newer HTTP versions send the same information in a more compact binary form, but the ideas are identical.

Methods and status codes you will meet first

ItemMeaningBrew & Bean example
GETRead somethingGET /menu returns the menu
POSTCreate somethingPOST /orders places a new order
PATCHChange part of somethingPATCH /orders/42/status marks it ready
200 OKIt workedThe menu came back
201 CreatedA new thing was createdThe order was saved
404 Not FoundNo such resourceGET /orders/99999
500 Internal Server ErrorThe server crashed or has a bugNot your request's fault

This lesson only needs the basics. Methods, status codes and headers are covered in depth in *HTTP in depth: methods, status codes and headers* in the Backend Development track.

Step 4: the browser builds the page

What the browser does with the response

  1. 1It reads the HTML from top to bottom and builds the DOM (Document Object Model): a tree of objects, one per element, that JavaScript can read and change.
  2. 2When it meets <link rel="stylesheet">, <script> or <img>, it sends more HTTP requests for those files. One page often needs dozens of requests.
  3. 3It applies CSS rules to the DOM to work out each element's colour, size and position (layout).
  4. 4It paints pixels on the screen.
  5. 5It runs JavaScript, which can change the DOM at any time. When the DOM changes, the browser updates the screen.

That last step is where React lives. React is a JavaScript library that keeps the DOM in sync with your data. When a customer adds a cappuccino to the cart, your code changes the data, and React works out which parts of the DOM to update. You will build exactly this in *State and events*.

Where React fits: two ways to build a site

Server-rendered pages vs a single-page app

QuestionServer-rendered (multi-page)Single-page app (SPA)
Who builds the HTML?The server, for every pageJavaScript in the browser
What happens on a link click?A full new page loadsJavaScript swaps the content, no full reload
What does the server send after the first load?More HTML pagesMostly JSON data from an API
Typical toolsPHP, Django, Rails, plain HTMLReact + Vite, Vue, Angular

A React app built with Vite starts as an almost empty HTML page plus a JavaScript bundle. The JavaScript builds the whole interface in the browser and fetches data (such as the Brew & Bean menu from GET /menu) as JSON. Frameworks such as Next.js mix both approaches by rendering React on the server; that comes later in *Next.js: server rendering and when you need it*.

Watch it happen in DevTools

Open any site in Chrome, Edge or Firefox, press F12 (or Ctrl+Shift+I; Cmd+Option+I on a Mac) and open the Network tab. Reload the page. Every row is one HTTP request. Click a row to see its method, status code, headers and response. This is the single most useful debugging tool for web developers.

Terminal
curl -I https://example.com

Sends a request and prints only the response status line and headers. curl is built into Windows 10 and later, macOS and most Linux systems. Look for the status code and Content-Type.

Common misconceptions

Clear these up early

  1. The internet and the web are not the same: the internet is the network; the web is one service (HTTP) running on it, like email is another.
  2. HTTPS does not mean a site is safe or honest. It means the connection is encrypted and you are talking to the domain in the address bar.
  3. "Frontend" code runs on the user's device. Anyone can read it in DevTools, so never put passwords or secret API keys in React code.
  4. A slow page is not always a slow server. Large images, too many requests and heavy JavaScript on a slow mobile network are common causes.
  5. Refreshing a page re-runs everything: a fresh request, a fresh DOM and fresh JavaScript. Data kept only in JavaScript variables is lost.

Secrets in frontend code are public

Every file the browser downloads can be read by the user. If you put an API key in a React app, treat it as published. Keys that must stay secret belong on a server, which calls the paid API on the browser's behalf.

How this comes up in interviews

"What happens when you type a URL and press Enter?" is one of the most common web interview questions, for freshers and experienced developers alike. A strong answer walks through the same steps as this lesson, in order: parse the URL, DNS lookup, TCP connection and TLS handshake, HTTP request, server response, then parsing HTML into the DOM, fetching CSS/JS/images, layout, paint and running JavaScript. Mention caching (DNS and browser cache) to show depth.

Prompt · Practise the classic interview question with AI
You are a frontend interviewer at a product company in India.

Ask me: "What happens when you type a URL into the browser and press Enter?" Wait for my answer.

Then:
1. Score my answer out of 10.
2. List the steps I missed or got in the wrong order.
3. Ask me one follow-up question about [DNS caching / HTTPS / how the browser renders HTML].

My level: [fresher / 2 years of experience].

What to expect: A good session points out missing steps (often DNS caching, the TLS handshake or the DOM) and asks a follow-up that goes one level deeper.

Try it: Trace a real page load

Open a news site you use, open DevTools, go to the Network tab and reload.

1. Find the first request. What is its method, status code and Content-Type? 2. How many requests did the page make in total, and how many are images? 3. Find one request that returned JSON (filter by Fetch/XHR). What data does it seem to carry? 4. Run nslookup on the site's domain and note the IP address.

Key takeaways

  1. The web is a conversation: the browser sends HTTP requests, servers send HTTP responses.
  2. A URL names the scheme, host, path and options of what you want; DNS turns the host into an IP address.
  3. A response has a status code, headers and a body (HTML, CSS, JS, images or JSON).
  4. The browser parses HTML into the DOM, applies CSS, paints, and runs JavaScript that can change the DOM.
  5. React keeps the DOM in sync with your data; a Vite React app builds its UI in the browser and fetches JSON from APIs.
  6. Frontend code is public; DevTools' Network tab shows every request your page makes.

Check yourself

Finishing the quiz marks the lesson as done.

1. You type https://brewandbean.example/menu and press Enter. What must happen before the browser can send the HTTP request?

2. A request to GET /orders/99999 returns status 404. What does that tell you?

3. Which statement about a single-page app built with React and Vite is correct?

4. A teammate wants to put a paid API's secret key in a React component so the app can call the API directly. What is the problem?

5. What is the DOM?

Saved on this device. Create a free account to keep it on every device.

Practise this with Sam

A real mock interview, out loud, with an honest scorecard. Free to start.

Start free