From daadd91eba85c3cf0cb11edd9c48a92a375dc9dc Mon Sep 17 00:00:00 2001 From: spastorelli Date: Fri, 19 Jun 2026 11:39:12 +0200 Subject: [PATCH] Fix NextLink prefetch side effect on unsigned claims persistance (#4325) --- .../src/components/primitives/Link.tsx | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/packages/gitbook/src/components/primitives/Link.tsx b/packages/gitbook/src/components/primitives/Link.tsx index c88d5a432..33324cd70 100644 --- a/packages/gitbook/src/components/primitives/Link.tsx +++ b/packages/gitbook/src/components/primitives/Link.tsx @@ -157,9 +157,14 @@ export function Link(props: LinkProps) { ); } - // Not sure why yet, but it seems necessary to force prefetch to true - // default behavior doesn't seem to properly use the client router cache. - const _prefetch = prefetch === null || prefetch === undefined ? true : prefetch; + // Not sure why yet, but forcing prefetch to true seems necessary for the + // client router cache to be used properly. + // + // However, we need to disable prefetch for links with query params that + // can trigger server-side side effects, such as persisting visitor claims in a + // cookie or starting the assistant. Automatic RSC prefetch requests can otherwise + // trigger those effects without user intent. + const _prefetch = hasSideEffectQueryParams(href) ? false : (prefetch ?? true); return (