state.router.link
stores the current URL. We demonstrated this by manually changing the URL in the browser's address bar and saw how the URL in our <p>
element changed as the component reacted to the data change.<Link>
component. The simplest way to use it is to just provide a link
attribute with the URL as its value:<Link>
component simply outputs an <a>
element into the resulting HTML, but without forcing a page reload which is what would occur if you simply added an <a>
element instead of using the <Link>
component.@frontity/components
.<Link>
component into our root component file for use within our <Root>
component. Let's add this import statement as the third line:<nav>
element with three <Link>
items as children. Using the example above as a template our index.js
file can now look like this:state.router.link
.<Link>
component in the simplest possible way. To learn more about what you can do with the <Link>
component, including pre-fetching strategies to make your site more responsive, see this page in our documentation.