Links

Links between pages are plain <a> tags. The router catches a click on any link to one of your own paths, renders the new page in place and adds it to the history, so Back and Forward work. Nothing reloads.

Write the href with link(): href={ link('/playlist') }. It prints a plain path in a normal app, and the right form for whichever router mode the app uses, so the same template works everywhere.

Your turn

  1. In Shop.pzl, make the brand a link home and add a small nav to the header:
<header>
  <a class="brand" href={ link('/') }>Music</a>
  <nav>
    <a href={ link('/') }>Shop</a>
    <a href={ link('/playlist') }>Your playlist</a>
  </nav>
</header>
  1. Give Playlist.pzl the same header, so you can get back.
  2. Click between the two pages, then try the preview's back and forward buttons.

You just wrote the same header twice. The next lesson fixes that.

Chapters