Next.js Discord

Discord Forum

Active link styles in a Server Component?

Answered
Pink salmon posted this in #help-forum
Open in Discord
Avatar
Pink salmonOP
I'm watching a tutorial. The guy uses usePathname to determine active link styles. This forces the component to be a Client Component.

Could it not remain as a Server Component if he had elected to use the server props that give the current pathname? Or is it the nature of a Client Component that allows the active styles to dynamically change?
Answered by B33fb0n3
well... usePathname is the only function to get the pathname and this hook is only clientside. So they NEED to be clientside. You may be confused, because you can get the searchparams serverside @Pink salmon
View full answer

2 Replies

Avatar
B33fb0n3
well... usePathname is the only function to get the pathname and this hook is only clientside. So they NEED to be clientside. You may be confused, because you can get the searchparams serverside @Pink salmon
Answer
Avatar
Pink salmonOP
You're right, thank you for clarifying this! Have a good day.