Next.js Discord

Discord Forum

How to get current url pathname in nextjs server components

Unanswered
Crazy ant posted this in #help-forum
Open in Discord
Crazy antOP
Could anyone tell me how I extract url pathname in server components since useRouter and usePathname hooks are working only in client components.

2 Replies

Crazy antOP
The link you shared I went through and I know that I can use params to get url params. But I want to get whole url pathname in server component instead of getting only params . url pathname like /profile/${userId}/settings