Next.js Discord

Discord Forum

Capturing client side values when the app renders and using them server side.

Unanswered
Tonkinese posted this in #help-forum
Open in Discord
TonkineseOP
Using next app router is there a way to capture client side values, like domain, site slug etc, and use them in server side components. A context won't work as a component needs to be a client to access the values and I don't want to pass the values as props as the components are heavily nested.

What are other people using to capture these values server side?

3 Replies

TonkineseOP
params are only available on that particular page. What if you want to get the site slug in a nested server component?
Use server-only-context in certain cases, impossible in others. https://nextjs-faq.com/get-pathname-in-rsc