Introduction to Routing

Learn about routing in Ember, generating routes, and different types of routes in Ember.

Routing is an essential part of any web application development framework. Routing provides an easy way to navigate through the various stages of our application. Ember has a powerful router with a wide range of features. We have a router.js file in our app directory. This contains the site map of our application. The router.js file is responsible for mapping all our routes in the browser. Let’s see how we can generate routes.

Creating a route in Ember

There are two ways to create a route in an Ember application. We can create a route manually or run an Ember CLI command.

Creating a route manually

Let’s first discuss the manual route creation. Suppose we want to create a cart route in our e-commerce application. We perform the following steps:

  • Create a file in the app/routes directory and name it cart.js.
  • Create a template for our route in the app/templates directory named cart.hbs.

Note: The names of the route, cart.js, and the template, cart.hbs, should be the same. This enables the Ember router to match the template to the route.

Our route is ready to load. However, we also need to specify in our application to ...