Chapter 8. Single-page applications

 

This chapter covers

  • Working with multiple modules
  • Optimizing performance with Html.Lazy
  • Routing
  • Parsing URLs

Our manager adores the two pages we’ve built for Photo Groove, and has a visionary idea for where to go next: “Now that we have all these pages, we need a header across the top with links so users can get between them quickly. Oh! And make sure it doesn’t do that unsightly flash of blank page when switching between them. That drives me bananas.”

Indeed, two pages is a lot more than one; a header to switch between them sounds like just what the doctor ordered.

In this chapter, we’ll build a navigation header that is shared between the two pages we’ve built in the previous chapters. We’ll build the combined page by using a single-page application (SPA) architecture, so users can transition between the two pages without the browser performing a fresh page load.

The “single page” in “single-page application” refers to a single page load—the browser loads the page only once. From the user’s perspective, all the usual features of multiple pages still appear to work as normal: the URL in the address bar changes when clicking links, the browser’s Back button still returns to the previous URL, and so on. Let’s build ourselves a single-page application!

8.1. Framing the page

8.2. Routing

8.3. Delegating pages

Summary

sitemap