Learn Next.js: Navigating Between Pages | Next.js
In the previous chapter, you created the dashboard layout and pages. Now, let's add some links to allow users to navigate between the dashboard routes. In this chapter... Here are the topics we’ll cover How to use the next/link component. How to show an active link with the usePathname() hook. How navigation works in Next.js. To link between pages, you'd traditionally use the <a> HTML element. At the moment, the sidebar links use <a> elements, but notice what happens when you navigate between the home, invoices, and customers pages on your browser. Did you see it? There's a full page refresh on each page navigation! In Next.js, you can use the <Link /> Component to link between pages in your application. <Link> allows you to do client-side navigation with JavaScript. To use the <Link /> component, open /app/ui/dashboard/nav-links.tsx, and import the Link component from next/link. Then, replace the <a> tag with <Link>: As you can see, the Link component is similar to using <a> tags, but
5 Chapter 5 Navigating Between Pages In the previous chapter, you created the dashboard layout and pages. Now, let's add some links to allow users to navigate between the dashboard routes. In this chapter... Here are the topics we'll cover How to use the next/link component. How to show an active link with the usePathname() hook. How navigation works in Next.js. Why optimize navigation? To link between pages, you'd traditionally use the <a> HTML element. At the moment, the sidebar links use <a> elements, but notice what happens when you navigate between the home, invoices, and customers pages
Explore this link on the map →saved by
related reading
- Getting Started: Layouts and Pages | Next.jsnextjs.org
- Getting Started: Linking and Navigating | Next.jsnextjs.org
- Building a single-page application with Next.js and React Routercolinhacks.com
- Getting Started: Layouts and Pages | Next.jsnextjs.org
- File-system conventions: loading.js | Next.jsnextjs.org
- App Router: Streaming | Next.jsnextjs.org
- Cursor Docs — Agent, Rules, MCP, Skills & CLIdocs.cursor.com
- Getting Started: Error Handling | Next.jsnextjs.org
- GitHub - emanuelefavero/next-js: A Next.js cheat sheet repository · GitHubgithub.com
- Getting Started: Fetching Data | Next.jsnextjs.org
- projects, claire wangclairebookworm.com
- Getting Started: Caching | Next.jsnextjs.org