What is routing?

Routing is how users navigate within a JavaScript web application. Routing strategies generally fall on a continuum between packing a router in your application or using the web browser's normal routing.

Routing is a key function of JavaScript UI frameworks and libraries

Routing is how users navigate within different pages and views within an application. Routing is one of the most important parts of providing a good experience for users within JavaScript web applications. Inefficient, confusing, or slow routing can quickly frustrate users and cause users to abandon a web application.

Many JavaScript frameworks include functionality for routing to ensure navigation through applications works properly. These applications have to avoid full page reloads inside of users’ web browsers because reloading the page could disrupt the state of the application or cause unexpected behavior.

Other JavaScript frameworks and libraries, however, rely on the web browser’s built-in navigation. They are designed to have no problems with full page reloads and can carry state through full page reloads.

Most tools for building user interfaces with JavaScript use either of those strategies or fall somewhere in between. Some frameworks have routing functionality built-in like Angular. Others rely on plugins for routing like React or Vue.js. Frameworks and libraries like Svelte just use the web browser’s normal navigation for routing by default.

Routing determines how pages inside of the application load when accessed by direct URL

The way routing works inside of an application directly determines how the page loads when you access the page directly. Applications that do not use the web browser’s normal navigation can sometimes have trouble loading properly when accessing an internal page by a direct URL. This can cause such an application to load incorrectly when the web application is being processed by a search engine’s page crawler.

Frameworks and libraries that rely on the web browser’s normal navigation usually do not have the same problem. They can usually load the correct page when visited using a direct URL.