← Lessons

quiz vs the machine

Gold1320

Frontend

Not Found Handling

Render a helpful 404 view and return the correct status for unmatched routes.

4 min read · core · beat Gold to climb

What it is

Not found handling decides what happens when a URL matches no route. A good app shows a clear 404 view that helps the user recover instead of a blank screen or a crash.

Two layers

  • The client router needs a catch all or wildcard route that matches anything unmatched and renders the 404 UI.
  • The server should return a real 404 status for those URLs so crawlers and tools see the truth.

A common bug is a soft 404: the app shows a not found page but the server replied 200, which confuses search engines and monitoring.

A helpful page

Offer a search box, a link home, and maybe suggestions. Preserve the attempted URL so the user understands what failed and you can log broken links.

Why it matters

Clean not found handling avoids dead ends, protects SEO with correct status codes, and surfaces broken links you can fix.

Key idea

Match unmatched URLs with a wildcard route to a helpful 404 view, and return a real 404 status to avoid soft errors.

Check yourself

Answer to earn rating on the learn ladder.

1. What catches a URL that matches no defined route?

2. What is a soft 404?