Thinking In Web State With React Router 7

2025-09-20T18:48:00.000Z
17 views

Remix is Dead, Long Live Remix!

/blogs/web-state-with-react-router-7/url-state

URL As State

State can be stored and accessed in the URL via the path or query params.


To illustrate the URL as a form of state I'm using <Outlet /> to render this "URL as State" section, as well as the other two sections in this blog post. Because each section is tied to a path, you can use the browser's back button or <Link>. No need to wire up some complicated state system to give the user that feature.


Query params allow for more complex behavior without navigating away from a particular path. State is still stored in the URL, but now the page is a bit more dynamic.


Here's a list of 100 candies from around the world. Both pagination and filtering happens via url query params. The list of candies is a JSON object hard coded to the page, so no database queries.


CANDY FILE
Types
Countries
Page 1 / 20100 results
  • Snickers

    United States

    A chocolate bar with nougat, caramel, and peanuts covered in milk chocolate.

  • Mars Bar

    United Kingdom

    A classic bar of nougat and caramel enrobed in milk chocolate.

  • Twix

    United Kingdom

    Crisp biscuit fingers topped with caramel and coated in chocolate.

  • Kit Kat

    United Kingdom

    Crisp wafer fingers covered in chocolate and made to be snapped and shared.

  • Milky Way (US)

    United States

    A fluffy nougat center layered with caramel and coated in chocolate.

Page 1 / 20100 results
How React Router Handles Query Updates

In React Router, changing the query string is a client side navigation, not a full page reload. On query changes, React Router:


  • Updates browser history
  • Resets scroll behavior by default
  • Revalidates loaders (more on this in the "Server as State" section)
RICKY
KISSOON