Optional Routes and Query Strings

Learn how to enable the filtering of contacts using URLs and providing navigation.

Our filtering works great, but we should really have the filtering criterion reflected in the URL. That way, users can bookmark their filters and navigate using the back and forward browser buttons.

Updating the URL with the filter button

First, let’s get the URL updated when we filter. We can add an event listener that will update the URL fragment:

Get hands-on with 1200+ tech skills courses.