Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/web/src/components/menu.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use client';

import classnames from 'classnames';
import Link from 'next/link';
import { usePathname } from 'next/navigation';
import * as React from 'react';
import { Drawer } from 'vaul';
import { SmartLink } from './smart-link';

interface MenuItemProps {
className?: string;
Expand All @@ -31,7 +31,7 @@ function MenuItem({ className, children, href, onClick }: MenuItemProps) {

return (
<li className="inline-flex w-full items-center justify-center md:w-fit">
<Link
<SmartLink
className={classnames(
'inline-flex h-8 scroll-m-2 items-center rounded-md text-slate-11 text-sm transition-colors hover:bg-slate-6 hover:text-slate-12 focus:bg-slate-6 focus:outline-none focus:ring focus:ring-slate-3 md:justify-center',
'data-[active=true]:bg-slate-6 data-[active=true]:text-slate-12',
Expand All @@ -43,7 +43,7 @@ function MenuItem({ className, children, href, onClick }: MenuItemProps) {
data-active={activeItem === href.replace('/', '')}
>
{children}
</Link>
</SmartLink>
</li>
);
}
Expand Down
28 changes: 28 additions & 0 deletions apps/web/src/components/smart-link.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Link from 'next/link';
import type { ComponentProps } from 'react';

const EXTERNAL_REWRITE_PATHS = ['/docs'];

type SmartLinkProps = ComponentProps<typeof Link>;

/**
* We'll temporarily use <a> to redirect to external domains -- apparently Next.js 16 has a router regression
* where <Link> components try to do client-side navigation for rewritten paths (e.g., /docs -> mintlify.com)
* The router doesn't detect these are external rewrites and attempts to fetch RSC payloads by adding
* ?_rsc= query params (since the external domain doesn't serve RSC payloads, navigation fails)
*
* Context:
* https://resend.slack.com/archives/C05R55V6GBF/p1763739968845719?thread_ts=1763732012.356639&cid=C05R55V6GBF
* https://github.com/vercel/next.js/issues/86385
*/
export function SmartLink({ href, ...props }: SmartLinkProps) {
const isExternalRewrite =
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Nov 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SmartLink accepts UrlObject hrefs but the external rewrite check only handles strings, so /docs rewrites expressed as UrlObjects never hit the <a> fallback and the router bug remains.

Prompt for AI agents
Address the following comment on apps/web/src/components/smart-link.tsx at line 19:

<comment>`SmartLink` accepts UrlObject `href`s but the external rewrite check only handles strings, so `/docs` rewrites expressed as UrlObjects never hit the `&lt;a&gt;` fallback and the router bug remains.</comment>

<file context>
@@ -0,0 +1,28 @@
+ * https://resend.slack.com/archives/C05R55V6GBF/p1763739968845719?thread_ts=1763732012.356639&amp;cid=C05R55V6GBF
+ */
+export function SmartLink({ href, ...props }: SmartLinkProps) {
+  const isExternalRewrite =
+    typeof href === &#39;string&#39; &amp;&amp;
+    EXTERNAL_REWRITE_PATHS.some((path) =&gt; href.startsWith(path));
</file context>
Fix with Cubic

typeof href === 'string' &&
EXTERNAL_REWRITE_PATHS.some((path) => href.startsWith(path));

if (isExternalRewrite) {
return <a href={href} {...(props as ComponentProps<'a'>)} />;
}

return <Link href={href} {...props} />;
}