How to prevent Link component from calling SSR components with _rsc at the end of the URL?
Answered
Transvaal lion posted this in #help-forum

Transvaal lionOP
I've been using Next's [Link component ](https://nextjs.org/docs/app/api-reference/components/link) all over my code, as per good practices and recommendations. I've also written all of
where in reality their canonical URLs are just
page.tsx
components to accommodate for SSR e.g. moved client-side components down the tree etc. to maximize performance. Unfortunately, as I noticed in production, and later read in the [docs](https://nextjs.org/docs/app/building-your-application/rendering/server-components), the <Link/>
component fetches a given page by adding _rsc=XXXXX
at the end of the href, where XXX
is some kind of id, regardless of whether it prefetches the page or not. This _rsc
suffix tells Next.js to fetch a React Server Component optimized binary of the given page that was created during a production build. This behavior confuses Google Search Console greatly, as I have a lot of "duplicate page with the same canonical URL" entries like so:https://www.domain.com/page1_rsc=XXXXX
https://www.domain.com/page2_rsc=XXXXX
where in reality their canonical URLs are just
https://www.domain.com/page1
etc. This happens due to Google bot scanning pages, and following links like a normal browser would do. I couldn't find any clue on how to prevent this behavior, so I replaced all <Link/>
components with a standard <a>
tag. Is there any way to use <Link/>
component, retain SSR, and get rid of this _rsc
suffix? Or tell Google bot that this _rsc
refers to the same component?Answered by Ray
By default, next prefetch all the
It can be disabled by setting
For you case, I think it is worth to open an issue on their github if no similar issue exist
<Link />
on the viewport in production which make a request to the route with ?_rsc=xxx
for faster navigation. It can be disabled by setting
prefetch
props on <Link />
to false.For you case, I think it is worth to open an issue on their github if no similar issue exist
4 Replies

@Transvaal lion I've been using Next's [Link component ](https://nextjs.org/docs/app/api-reference/components/link) all over my code, as per good practices and recommendations. I've also written all of `page.tsx` components to accommodate for SSR e.g. moved client-side components down the tree etc. to maximize performance. Unfortunately, as I noticed in production, and later read in the [docs](https://nextjs.org/docs/app/building-your-application/rendering/server-components), the `<Link/>` component fetches a given page by adding `_rsc=XXXXX` at the end of the href, where `XXX` is some kind of id, regardless of whether it prefetches the page or not. This `_rsc` suffix tells Next.js to fetch a React Server Component optimized binary of the given page that was created during a production build. This behavior confuses Google Search Console greatly, as I have a lot of "duplicate page with the same canonical URL" entries like so:
https://www.domain.com/page1_rsc=XXXXX
https://www.domain.com/page2_rsc=XXXXX
where in reality their canonical URLs are just `https://www.domain.com/page1` etc. This happens due to Google bot scanning pages, and following links like a normal browser would do. I couldn't find any clue on how to prevent this behavior, so I replaced all `<Link/>` components with a standard `<a>` tag. Is there any way to use `<Link/>` component, retain SSR, and get rid of this `_rsc` suffix? Or tell Google bot that this `_rsc` refers to the same component?

By default, next prefetch all the
It can be disabled by setting
For you case, I think it is worth to open an issue on their github if no similar issue exist
<Link />
on the viewport in production which make a request to the route with ?_rsc=xxx
for faster navigation. It can be disabled by setting
prefetch
props on <Link />
to false.For you case, I think it is worth to open an issue on their github if no similar issue exist
Answer

Transvaal lionOP
Will setting
On the side note, I observe other weird suffixes like
what's with that?
prefetch
to false
help though? I replaced all <Link/>
with <a/>
and GSC still complains about ?_rsc=XXX
so it got me thinking that even though pages are not dynamically prefetched, GSC still finds out that an <a/>
redirects to a RSC component.On the side note, I observe other weird suffixes like
?trk=public_post_comment-text
what's with that?

I don't see any request made to
and Ive never seen
?_rsc=xxx
with <a />
and Ive never seen
?trk=public_post_comment-text
too
Transvaal lionOP
okay, I will create a github issue then