Why can't we get pathName in server component ? #58212
Answered
by
mutasim77
anhVuducTimego
asked this question in
Help
-
SummaryHI, I just want to highlight a menu link in a server component by compare pathname with href property in link, but look like there is no way to get pathname on server. Additional informationNo response ExampleNo response |
Beta Was this translation helpful? Give feedback.
Answered by
mutasim77
Nov 9, 2023
Replies: 1 comment 2 replies
-
just use import { headers } from "next/headers";
const header = headers();
const pathname = header.get('next-url')
console.log('pathName:', pathname); |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
anhVuducTimego
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
just use
headers
from next: