Skip to content

Why can't we get pathName in server component ? #58212

Answered by mutasim77
anhVuducTimego asked this question in Help
Discussion options

You must be logged in to vote

just use headers from next:

import { headers } from "next/headers";

const header = headers();
const pathname = header.get('next-url')
console.log('pathName:', pathname);

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@levchenkod
Comment options

@kimhwanhoon
Comment options

Answer selected by anhVuducTimego
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
4 participants