Comment

Comment by fnky

I've had the encountered same problem when trying to just get the request path in order to highlight the current active page link in a navigation. It's simply not possible with Server Components only.

I ended up having to wrap each nav link in a client-side component, meaning the active state is lost in no-JS land (but will still render the nav on the server). The provider just wraps the link to provide a class, which can then be used to identify, with CSS, which link is active.

I really don't understand how cookies and headers can be provided, but not even just the requested path.

parent fnky 3 years ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton