Is there a way to get url params inside of server component?
Answered
Cinnamon posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
CinnamonOP
like context param in
getServerSideProps
on page directory before?Answered by joulev
Use the params and searchParams props: https://nextjs.org/docs/app/api-reference/file-conventions/page#params-optional
10 Replies
![Avatar](https://cdn.discordapp.com/avatars/484037068239142956/f386ac21405ce3442e0f3598223e1cb3.webp?size=256)
joulev
Use the params and searchParams props: https://nextjs.org/docs/app/api-reference/file-conventions/page#params-optional
Answer
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
CinnamonOP
Awesome! That's exactly what i want thank you 🙇â€â™‚ï¸
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Californian
Is it possible to get query params eg
I want to get the category value
http://localhost:3000/about/blog?category=ENGINEERING&DESIGN
from pages folder instead of app folder?I want to get the category value
![Avatar](https://cdn.discordapp.com/avatars/572329183334891520/3ea2e2e134a2327e2b8a7738876a17b5.webp?size=256)
fuma 💙 joulev
useRouter
works![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Californian
Mine doesn't work.
Could you share an example?
Could you share an example?
const router = useRouter()
console.log(router.query)
router.query returns null
![Avatar](https://cdn.discordapp.com/avatars/572329183334891520/3ea2e2e134a2327e2b8a7738876a17b5.webp?size=256)
fuma 💙 joulev
it's an empty object when pre-rendering unless you're using SSR (according to the docs)
Check your console in the devtools
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Californian
It is now working on browser console. Thanks!