Next.js Discord

Discord Forum

usePathname excludes # in the url

Answered
Black-bellied Whistling-Duck posted this in #help-forum
Open in Discord
Black-bellied Whistling-DuckOP
My url contains /account#profile but when I use usePathname it only returns /account . So how do I access #profile ?
Answered by joulev
the hash is not sent to the server, you have to use a client component and access window.location.hash in useEffect or event handler or similar
View full answer

2 Replies

@Black-bellied Whistling-Duck My url contains `/account#profile` but when I use usePathname it only returns `/account` . So how do I access `#profile` ?
the hash is not sent to the server, you have to use a client component and access window.location.hash in useEffect or event handler or similar
Answer
Black-bellied Whistling-DuckOP
ok sure thanks