Next.js Discord

Discord Forum

Best practices for creating a sidebar on ssr

Answered
Dwarf Crocodile posted this in #help-forum
Open in Discord
Avatar
Dwarf CrocodileOP
Do you all have any best practices for creating a sidebar on ssr where you can put the sidebar in the layout and set the selected item from the page? I used contexts in pages to achieve this but they're not available on the server
Answered by DirtyCajunRice | AppDir
so you wrap just the text part in a client component that uses usePath to decerrn whether the css for highlighting is added
View full answer

10 Replies

Avatar
explain more about what is being selected.
Avatar
Dwarf CrocodileOP
just one of the items in the list like thhis example
Image
nothing spectacular
Avatar
is that not just navigation…
why arent you just using links
those should all be pages
Avatar
Dwarf CrocodileOP
Yes it's just navigation but the design requires to have some highlight of which page you are on
Those are all links
Avatar
@Dwarf Crocodile Yes it's just navigation but the design requires to have some highlight of which page you are on
Avatar
so you wrap just the text part in a client component that uses usePath to decerrn whether the css for highlighting is added
Answer
Avatar
Dwarf CrocodileOP
Oh i hadn't thought of that, thank you