Search⌘ K
AI Features

How Routing Works

Explore how routing operates in Ember.js to manage URLs and application structure. Understand routing configurations, state handling, and navigation methods to build dynamic web applications effectively.

Routing configurations

The router.js file contains the configurations of our routes. It acts as a site map for the Ember application. This file contains the definition of all our routes. We can get an overview of our application structure by looking at the router.js file. Let’s bring it up in our editor and discuss its details:

Javascript (babel-node)
// app/router.js
import EmberRouter from '@ember/routing/router';
import config from 'ecommerce-app/config/environment';
export default class Router extends EmberRouter {
location = config.locationType;
rootURL = config.rootURL;
}
Router.map(function () {
});
  • Line 2: We import the EmberRouter class from @ember/routing/router. The EmberRouter class is responsible for managing URLs and the state of our application.

  • Line 3: We ...