Next.js Discord

Discord Forum

how to detect client side navigation in RSC?

Unanswered
Polar bear posted this in #help-forum
Open in Discord
Polar bearOP
I am trying to see if there is an "official" way to check if a user performd a client navigation to a page within the page's RSC. In the past, I have seen people check for the headers' next-url header but I don't see this header in next 16! Thanks 🙂

1 Reply

@Polar bear I am trying to see if there is an "official" way to check if a user performd a client navigation to a page within the page's RSC. In the past, I have seen people check for the headers' next-url header but I don't see this header in next 16! Thanks 🙂
Azawakh
In Next.js 16, there is no official way to detect client navigation in an RSC.
The next-url header is unstable and often missing.
Best workaround:
Check for the _rsc query param using x-url header:
__

import { headers } from 'next/headers';
const isClientNav = new URL(headers().get('x-url')!).searchParams.has('_rsc');
__

true = client navigation (via <Link> or router.push)
false = hard refresh or direct visit
That’s the most reliable method today.