0

It is said that in next js we don't need to install react-router-dom because the path of our pages depend on the pages folder. Well, it actually works when I create button to move to another pages. But when I create components folder and create navbar component, it doesn't work properly as it was. The next/link keeps reloading when it moves to another pages.

import Link from "next/link";

export default function Navbar() {
  return (
    <nav className="bg-black flex justify-between p-5 text-white">
      <h1 className="font-bold text-sky-400">
        <Link href="/">Furniture App</Link>
      </h1>
      <div>
        <Link href="about">About</Link>
        <Link href="promos">Promos</Link>
      </div>
    </nav>
  );
}

Do I have to create components in pages folder in order to make Next/Link works without reload the browser?

  • 1
    What do you mean `The next/link keeps reloading when it moves to another pages.`? And try to replace href to absolute path `/about` and `/promos` – vbykovsky Jan 07 '23 at 14:04
  • @vbykovsky he probably meant that clicking it causes a non-client-side routing (which shouldn't be the case) – Damzaky Jan 07 '23 at 14:07
  • From docs: `The Next.js router allows you to do client-side route transitions between pages, similar to a single-page application. A React component called Link is provided to do this client-side route transition.` – vbykovsky Jan 07 '23 at 14:10

0 Answers0