This is a simple react app that shows how to use the browser URL to manage state.
Note: The react app is built with Next.js App Router, the same approach can be used with React Router.
- Clone the repo, then run the following commands in the root directory
npm i
npm run dev
- open
http://localhost:3000
in your browser
The app allows you to open two routes:
/products
- Filter a list of products using URL search parameter/products-2
- Filter a list of products using useState hook
Both approaches have the same functionality, but the first one uses the URL to manage the state, while the second one uses the useState hook