NextJS 16.2.2, route groups, navbar, links not working #194411
Replies: 4 comments 2 replies
-
Fix for Navbar Links Not Working in Next.js (Route Groups)If your navbar links are not working when using route groups in Next.js 16+, the issue is usually related to how route groups are handled in URLs. 🔍 Root CauseRoute groups (folders wrapped in parentheses like So this structure: 👉 The actual route becomes: NOT: ✅ Fix 1: Correct your Link pathsMake sure you're linking to the actual route: import Link from 'next/link';
<Link href="/dashboard">Dashboard</Link>❌ Wrong: <Link href="/(main)/dashboard">Dashboard</Link>✅ Fix 2: Check layout placementIf your navbar is inside a route group layout like: 👉 It will only apply to routes inside that group. 📌 If you want a global navbar: ✅ Fix 3: Client vs Server ComponentIf your navbar uses interactivity (like onClick, state, etc.), ensure: 'use client';At the top of your navbar component. ✅ Fix 4: Navigation issues (App Router)If navigation is not triggering:
✅ Fix 5: Dev server cache issueSometimes changes don’t reflect properly: rm -rf .next
npm run dev💡 Extra TipRoute groups are only for organization — never include them in URLs or links. ✅ Summary
If you can share your folder structure, I can help pinpoint the exact issue. |
Beta Was this translation helpful? Give feedback.
-
|
Hard to say without seeing the header component, but this is usually one of two things. First, check you're using Second, if your header has any interactive elements (active state, mobile toggle, onClick), the component needs 'use client'
import Link from 'next/link'
export function Header() {
return (
<nav>
<Link href="/">Home</Link>
<Link href="/about">About</Link>
</nav>
)
}Also worth a quick DevTools check: open Elements, hover over one of the broken links, and confirm nothing else is sitting on top and intercepting clicks. A full-width overlay or z-index issue can block them silently. Can you share the header component? That'll make it easier to pinpoint. |
Beta Was this translation helpful? Give feedback.
-
|
Looking at the layout code you shared, I think I spotted the actual problem. Your return (
<html lang="en" className="hydrated">
<body cz-shortcut-listen="true">
<Header />
{children}
</body>
</html>
)Only the root Fix your import "../globals.css"
import Header from "@/components/shared/header"
export default function Layout({
children,
}: {
children: React.ReactNode
}) {
return (
<>
<Header />
{children}
</>
)
}The Also: Let me know if that fixes the navigation. |
Beta Was this translation helpful? Give feedback.
-
|
Adding to the existing answer — another common cause of navbar Check 1 — Are you using
|
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
🏷️ Discussion Type
Question
Body
My project structure:
The problem is that the links don't work in the header, but on the page. Maybe the structure is wrong?
Guidelines
Beta Was this translation helpful? Give feedback.
All reactions