Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
perf(ui): prefetch a link on press, not on hover
Sidwebworksa207600b2ab6
diff --git a/.ai/lessons.md b/.ai/lessons.mdindex ba0eb2c5d4..e4c41cf002 100644--- a/.ai/lessons.md+++ b/.ai/lessons.md@@ -988,7 +988,7 @@ canvas hosting Radix popovers/selects.**Rule:** `space-x-*` / `space-y-*` are structural (`:not(:last-child)`) — never use them on a container whose children a component may add to at runtime; use `gap-*`, which only applies between elements that generate boxes and so ignores `display:none`. When a component renders extra DOM next to its main element (React Router prefetch links, portals, measurement nodes), isolate it in a `display: contents` wrapper so it can't perturb the caller's layout. To diagnose "impossible" width changes, diff every computed property between states and count child nodes — a node-count delta with no style delta means injected DOM, not CSS.-**Applies to:** `apps/erp/app/components/Hyperlink.tsx`; `packages/react/src/{HStack,VStack}.tsx` (still `space-x-*`/`space-y-*`, ~2,500 call sites); any `<Link prefetch>` placed directly inside a `space-*` container.+**Applies to:** `apps/erp/app/components/Hyperlink.tsx`; `packages/react/src/{HStack,VStack}.tsx` (still `space-x-*`/`space-y-*`, ~2,500 call sites); any `PrefetchLink` (`@carbon/react`, which injects the same tags on press) or `<Link prefetch>` placed directly inside a `space-*` container.## A list-query benchmark that omits the ORDER BY measures a query the app never runsdiff --git a/apps/erp/app/components/Breadcrumb.tsx b/apps/erp/app/components/Breadcrumb.tsxindex 3fe6c164df..f31486705e 100644--- a/apps/erp/app/components/Breadcrumb.tsx+++ b/apps/erp/app/components/Breadcrumb.tsx@@ -2,12 +2,11 @@// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,// including ports, remain AGPLv3; serving them over a network requires releasing their source.-import { Button, cn, getValidChildren } from "@carbon/react";+import { Button, cn, getValidChildren, PrefetchLink } from "@carbon/react";import { useLingui } from "@lingui/react/macro";import type { ComponentProps } from "react";import { cloneElement, forwardRef } from "react";import type { LinkProps } from "react-router";-import { Link } from "react-router";const Breadcrumbs = forwardRef<HTMLElement,@@ -75,9 +74,9 @@ const BreadcrumbLink = forwardRef<{children}</span>) : (- <Link ref={ref} {...props} prefetch="intent">+ <PrefetchLink ref={ref} {...props}>{children}- </Link>+ </PrefetchLink>)}</Button>);diff --git a/apps/erp/app/components/Hyperlink.tsx b/apps/erp/app/components/Hyperlink.tsxindex 1f6bc06b1e..fdc40c347f 100644--- a/apps/erp/app/components/Hyperlink.tsx+++ b/apps/erp/app/components/Hyperlink.tsx@@ -2,11 +2,10 @@// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,// including ports, remain AGPLv3; serving them over a network requires releasing their source.-import { Button, cn } from "@carbon/react";+import { Button, cn, PrefetchLink } from "@carbon/react";import type { ComponentProps, PropsWithChildren } from "react";import { LuPanelRight } from "react-icons/lu";import type { LinkProps } from "react-router";-import { Link } from "react-router";const Hyperlink = ({children,@@ -22,8 +21,7 @@ const Hyperlink = ({// (a `:not(:last-child)` margin) hands the anchor a phantom 8px on hover —// which reflows the whole table column under `table-layout: auto`.<span className="contents">- <Link- prefetch="intent"+ <PrefetchLinkclassName={cn("group/hyperlink text-foreground font-medium cursor-pointer flex flex-row items-center justify-start gap-3",className@@ -46,7 +44,7 @@ const Hyperlink = ({Open</Button>)}- </Link>+ </PrefetchLink></span>) : (<span className={cn("text-foreground", className)} {...props}>diff --git a/apps/erp/app/components/Icons.tsx b/apps/erp/app/components/Icons.tsxindex fb4079b60f..1f91c6d202 100644--- a/apps/erp/app/components/Icons.tsx+++ b/apps/erp/app/components/Icons.tsx@@ -8,6 +8,7 @@ import { mapLinearStatusToCarbonStatus } from "@carbon/ee/linear";import {Badge,cn,+ PrefetchLink,Status,Tooltip,TooltipContent,@@ -74,7 +75,6 @@ import {} from "react-icons/lu";import { RxCodesandboxLogo } from "react-icons/rx";import { TbTargetOff } from "react-icons/tb";-import { Link } from "react-router";import { AlmostDoneIcon } from "~/assets/icons/AlmostDoneIcon";import { InProgressStatusIcon } from "~/assets/icons/InProgressStatusIcon";import { TodoStatusIcon } from "~/assets/icons/TodoStatusIcon";@@ -174,7 +174,7 @@ export function MethodBadge({ type, text, to, className }: MethodBadgeProps) {const mode = useMode();const style = getReplenishmentBadgeColor(type, mode);return (- <Link to={to} prefetch="intent" className="group flex items-center gap-1">+ <PrefetchLink to={to} className="group flex items-center gap-1"><Badge style={style} className={className}><MethodIcon type={type} className="w-3 h-3 mr-1 " />{text}@@ -182,7 +182,7 @@ export function MethodBadge({ type, text, to, className }: MethodBadgeProps) {<span className="group-hover:opacity-100 opacity-0 transition-opacity duration-200 w-4 h-4 text-foreground"><LuExternalLink /></span>- </Link>+ </PrefetchLink>);}diff --git a/apps/erp/app/components/Layout/Navigation/ContentSidebar.tsx b/apps/erp/app/components/Layout/Navigation/ContentSidebar.tsxindex 5246bbadae..b309bb1fa3 100644--- a/apps/erp/app/components/Layout/Navigation/ContentSidebar.tsx+++ b/apps/erp/app/components/Layout/Navigation/ContentSidebar.tsx@@ -2,8 +2,7 @@// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,// including ports, remain AGPLv3; serving them over a network requires releasing their source.-import { Button, cn, VStack } from "@carbon/react";-import { Link } from "react-router";+import { Button, cn, PrefetchLink, VStack } from "@carbon/react";import { useUrlParams } from "~/hooks";import type { Route } from "~/types";import { SidebarLinks, useSidebarLocation } from "./CollapsibleSidebar";@@ -35,12 +34,9 @@ const ContentSidebar = ({ links }: { links: Route[] }) => {"hover:bg-transparent hover:text-active-foreground")}>- <Link- to={route.to + (route.q ? `?q=${route.q}` : "")}- prefetch="intent"- >+ <PrefetchLink to={route.to + (route.q ? `?q=${route.q}` : "")}>{route.name}- </Link>+ </PrefetchLink></Button>);})}diff --git a/apps/erp/app/components/Layout/Navigation/DetailSidebar.tsx b/apps/erp/app/components/Layout/Navigation/DetailSidebar.tsxindex a6b6ed176c..938cb4eb89 100644--- a/apps/erp/app/components/Layout/Navigation/DetailSidebar.tsx+++ b/apps/erp/app/components/Layout/Navigation/DetailSidebar.tsx@@ -7,6 +7,7 @@ import {Button,Count,HStack,+ PrefetchLink,ShortcutKey,Tooltip,TooltipContent,@@ -16,7 +17,7 @@ import {} from "@carbon/react";import type { ReactNode } from "react";import { useMemo } from "react";-import { Link, useNavigate } from "react-router";+import { useNavigate } from "react-router";import { useOptimisticLocation } from "~/hooks";type DetailSidebarProps = {@@ -61,9 +62,8 @@ const DetailSidebar = ({ links }: DetailSidebarProps) => {variant={isActive ? "active" : "ghost"}className="w-full justify-start">- <Link+ <PrefetchLinkto={route.to}- prefetch="intent"className="flex items-center justify-start gap-2">{route.icon}@@ -71,7 +71,7 @@ const DetailSidebar = ({ links }: DetailSidebarProps) => {{route.count !== undefined && (<Count count={route.count} className="ml-auto" />)}- </Link>+ </PrefetchLink></Button></TooltipTrigger>{route.shortcut && (diff --git a/apps/erp/app/components/Layout/Navigation/DetailsTopbar.tsx b/apps/erp/app/components/Layout/Navigation/DetailsTopbar.tsxindex 5060ec1bec..3488f98f73 100644--- a/apps/erp/app/components/Layout/Navigation/DetailsTopbar.tsx+++ b/apps/erp/app/components/Layout/Navigation/DetailsTopbar.tsx@@ -7,6 +7,7 @@ import {Count,cn,HStack,+ PrefetchLink,ShortcutKey,Tooltip,TooltipContent,@@ -15,7 +16,7 @@ import {} from "@carbon/react";import { useMemo } from "react";import type { IconType } from "react-icons";-import { Link, useNavigate } from "react-router";+import { useNavigate } from "react-router";import { useOptimisticLocation, useUrlParams } from "~/hooks";type DetailTopbarProps = {@@ -76,9 +77,8 @@ const DetailTopbar = ({return (<Tooltip key={route.name}><TooltipTrigger className="w-full">- <Link+ <PrefetchLinkto={linkTo}- prefetch="intent"className={cn("inline-flex items-center justify-center whitespace-nowrap rounded-[6px] px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",isActive && "bg-background text-foreground shadow-button-base"@@ -89,7 +89,7 @@ const DetailTopbar = ({{route.count !== undefined && (<Count count={route.count} className="ml-auto" />)}- </Link>+ </PrefetchLink></TooltipTrigger>{route.shortcut && (<TooltipContent side="bottom">diff --git a/apps/erp/app/components/Layout/Navigation/GroupedContentSidebar.tsx b/apps/erp/app/components/Layout/Navigation/GroupedContentSidebar.tsxindex 528b1dec62..5bebea6f52 100644--- a/apps/erp/app/components/Layout/Navigation/GroupedContentSidebar.tsx+++ b/apps/erp/app/components/Layout/Navigation/GroupedContentSidebar.tsx@@ -12,6 +12,7 @@ import {DropdownMenuTrigger,IconButton,MENU_ITEM_SHORTCUTS,+ PrefetchLink,Subheading,useDebounce,VStack@@ -26,7 +27,7 @@ import {LuGripVertical,LuTrash} from "react-icons/lu";-import { Link, useSubmit } from "react-router";+import { useSubmit } from "react-router";import { ConfirmDelete } from "~/components/Modals";import type { RouteGroup } from "~/types";import { path } from "~/utils/path";@@ -137,12 +138,11 @@ const GroupedContentSidebar = ({: "hover:bg-transparent hover:text-active-foreground hover:scale-100 focus-visible:scale-100")}>- <Link+ <PrefetchLinkto={route.to + (route.q ? `?q=${route.q}` : "")}- prefetch="intent">{route.name}- </Link>+ </PrefetchLink></Button>{hasViews && (<IconButton@@ -270,9 +270,7 @@ const ViewsReorderGroup = ({: "hover:bg-transparent hover:text-active-foreground")}>- <Link to={view.to} prefetch="intent">- {view.name}- </Link>+ <PrefetchLink to={view.to}>{view.name}</PrefetchLink></Button><IconButtonaria-label={t`Drag handle`}diff --git a/apps/erp/app/modules/accounting/ui/Reports/AccountLedgerDrawer.tsx b/apps/erp/app/modules/accounting/ui/Reports/AccountLedgerDrawer.tsxindex 5fbea3c347..e89c4b71ec 100644--- a/apps/erp/app/modules/accounting/ui/Reports/AccountLedgerDrawer.tsx+++ b/apps/erp/app/modules/accounting/ui/Reports/AccountLedgerDrawer.tsx@@ -10,6 +10,7 @@ import {DrawerHeader,DrawerTitle,IconButton,+ PrefetchLink,Table,Tbody,Td,@@ -20,7 +21,7 @@ import {import { toDisplayCredit, toDisplayDebit } from "@carbon/utils";import { Trans, useLingui } from "@lingui/react/macro";import { LuChevronLeft, LuChevronRight } from "react-icons/lu";-import { Link, useNavigate } from "react-router";+import { useNavigate } from "react-router";import { useUrlParams } from "~/hooks";import type {AccountClass,@@ -178,13 +179,12 @@ const AccountLedgerDrawer = ({</Td><Td className="px-4 whitespace-nowrap"><div className="flex items-center gap-2">- <Link+ <PrefetchLinkto={path.to.journalEntryDetails(line.journalId)}- prefetch="intent"className="font-mono text-xs text-foreground hover:underline">{line.journalEntryId}- </Link>+ </PrefetchLink>{line.status !== "Posted" && (<JournalEntryStatus status={line.status} />)}diff --git a/apps/erp/app/modules/documents/ui/Documents/DocumentsTable.tsx b/apps/erp/app/modules/documents/ui/Documents/DocumentsTable.tsxindex bcedc7ff0d..df8378b919 100644--- a/apps/erp/app/modules/documents/ui/Documents/DocumentsTable.tsx+++ b/apps/erp/app/modules/documents/ui/Documents/DocumentsTable.tsx@@ -19,6 +19,7 @@ import {Popover,PopoverContent,PopoverTrigger,+ PrefetchLink,useDisclosure} from "@carbon/react";import { filterEmpty } from "@carbon/utils";@@ -41,7 +42,7 @@ import {LuUsers} from "react-icons/lu";import { RxCheck } from "react-icons/rx";-import { Link, useRevalidator } from "react-router";+import { useRevalidator } from "react-router";import { DateTime, EmployeeAvatar, Hyperlink, Table } from "~/components";import DocumentIcon from "~/components/DocumentIcon";import { Enumerable } from "~/components/Enumerable";@@ -215,20 +216,19 @@ const DocumentsTable = memo(cell: ({ row }) =>row.original.sourceDocument &&row.original.sourceDocumentId && (- <Link+ <PrefetchLinkto={getDocumentLocation(row.original.sourceDocument as (typeof documentSourceTypes)[number],row.original.sourceDocumentId)}- prefetch="intent"className="group flex items-center gap-1"><Enumerable value={row.original.sourceDocument} />{" "}<span className="group-hover:opacity-100 opacity-0 transition-opacity duration-200 w-4 h-4 text-foreground"><LuExternalLink /></span>- </Link>+ </PrefetchLink>),meta: {icon: <LuFileText />,diff --git a/apps/erp/app/modules/inventory/ui/StockMovements/StockMovementsTable.tsx b/apps/erp/app/modules/inventory/ui/StockMovements/StockMovementsTable.tsxindex a16d2ff348..ee2306efbc 100644--- a/apps/erp/app/modules/inventory/ui/StockMovements/StockMovementsTable.tsx+++ b/apps/erp/app/modules/inventory/ui/StockMovements/StockMovementsTable.tsx@@ -2,7 +2,14 @@// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,// including ports, remain AGPLv3; serving them over a network requires releasing their source.-import { Badge, HStack, MenuIcon, MenuItem, VStack } from "@carbon/react";+import {+ Badge,+ HStack,+ MenuIcon,+ MenuItem,+ PrefetchLink,+ VStack+} from "@carbon/react";import { useLingui } from "@lingui/react/macro";import type { ColumnDef } from "@tanstack/react-table";import { memo, useCallback, useMemo, useState } from "react";@@ -21,7 +28,6 @@ import {LuWarehouse,LuWrench} from "react-icons/lu";-import { Link } from "react-router";import {DateTime,EmployeeAvatar,@@ -203,13 +209,12 @@ const StockMovementsTable = memo(row.original.trackedEntityReadableId || trackedEntityId;if (!trackedEntityId) return label ?? "";return (- <Link- prefetch="intent"+ <PrefetchLinkto={`${path.to.traceabilityGraph}?trackedEntityId=${trackedEntityId}`}className="text-foreground hover:underline">{label}- </Link>+ </PrefetchLink>);},meta: {diff --git a/apps/erp/app/modules/inventory/ui/Traceability/StepRecordsList.tsx b/apps/erp/app/modules/inventory/ui/Traceability/StepRecordsList.tsxindex aab49bcc13..2b30e29b15 100644--- a/apps/erp/app/modules/inventory/ui/Traceability/StepRecordsList.tsx+++ b/apps/erp/app/modules/inventory/ui/Traceability/StepRecordsList.tsx@@ -2,10 +2,9 @@// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,// including ports, remain AGPLv3; serving them over a network requires releasing their source.-import { Checkbox, cn } from "@carbon/react";+import { Checkbox, cn, PrefetchLink } from "@carbon/react";import { useNumberFormatter } from "@react-aria/i18n";import { LuPaperclip } from "react-icons/lu";-import { Link } from "react-router";import { DateTime } from "~/components";import { useUnitOfMeasure } from "~/components/Form/UnitOfMeasure";import { ProcedureStepTypeIcon } from "~/components/Icons";@@ -71,14 +70,13 @@ export function StepRecordsList({ records, jobId }: Props) {return (<li key={r.id}>{href ? (- <Link+ <PrefetchLinkto={href}- prefetch="intent"className="block px-2 py-1.5 -mx-2 rounded-md hover:bg-accent/50 transition-colors"onClick={(e) => e.stopPropagation()}>{body}- </Link>+ </PrefetchLink>) : (<div className="py-1.5 first:pt-0 last:pb-0">{body}</div>)}diff --git a/apps/erp/app/modules/inventory/ui/Traceability/attributeRenderers.tsx b/apps/erp/app/modules/inventory/ui/Traceability/attributeRenderers.tsxindex 1c0c43cc89..cccbcb5c90 100644--- a/apps/erp/app/modules/inventory/ui/Traceability/attributeRenderers.tsx+++ b/apps/erp/app/modules/inventory/ui/Traceability/attributeRenderers.tsx@@ -3,13 +3,12 @@// including ports, remain AGPLv3; serving them over a network requires releasing their source.import { useCarbon } from "@carbon/auth";-import { cn, useMount } from "@carbon/react";+import { cn, PrefetchLink, useMount } from "@carbon/react";import type {TrackedActivityAttributes,TrackedEntityAttributes} from "@carbon/utils";import { useState } from "react";-import { Link } from "react-router";import { CustomerAvatar, EmployeeAvatar, SupplierAvatar } from "~/components";import { useWorkCenters } from "~/components/Form/WorkCenter";import { path } from "~/utils/path";@@ -24,9 +23,8 @@ function InlineLink({className?: string;}) {return (- <Link+ <PrefetchLinkto={to}- prefetch="intent"className={cn("text-sm font-medium text-foreground hover:underline truncate",className@@ -34,7 +32,7 @@ function InlineLink({onClick={(e) => e.stopPropagation()}>{children}- </Link>+ </PrefetchLink>);}diff --git a/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceExplorer.tsx b/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceExplorer.tsxindex 2c588ff598..8d34b88393 100644--- a/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceExplorer.tsx+++ b/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceExplorer.tsx@@ -16,6 +16,7 @@ import {HStack,IconButton,MENU_ITEM_SHORTCUTS,+ PrefetchLink,ShortcutKey,Tooltip,TooltipContent,@@ -332,9 +333,8 @@ function PurchaseInvoiceLineItem({return (<VStack spacing={0} className="border-b">- <Link+ <PrefetchLinkto={path.to.purchaseInvoiceLine(invoiceId, line.id!)}- prefetch="intent"className="w-full"><HStack@@ -410,7 +410,7 @@ function PurchaseInvoiceLineItem({</DropdownMenu></div></HStack>- </Link>+ </PrefetchLink></VStack>);}diff --git a/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceExplorer.tsx b/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceExplorer.tsxindex 2231b08b10..771ff01402 100644--- a/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceExplorer.tsx+++ b/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceExplorer.tsx@@ -13,6 +13,7 @@ import {HStack,IconButton,MENU_ITEM_SHORTCUTS,+ PrefetchLink,ShortcutKey,Tooltip,TooltipContent,@@ -285,9 +286,8 @@ function SalesInvoiceLineItem({return (<VStack spacing={0} className="border-b">- <Link+ <PrefetchLinkto={path.to.salesInvoiceLine(invoiceId, line.id!)}- prefetch="intent"className="w-full"><HStack@@ -359,7 +359,7 @@ function SalesInvoiceLineItem({</DropdownMenu></div></HStack>- </Link>+ </PrefetchLink></VStack>);}diff --git a/apps/erp/app/modules/items/ui/ChangeNotice/ChangeNoticeExplorer.tsx b/apps/erp/app/modules/items/ui/ChangeNotice/ChangeNoticeExplorer.tsxindex 2cbe606309..6297004910 100644--- a/apps/erp/app/modules/items/ui/ChangeNotice/ChangeNoticeExplorer.tsx+++ b/apps/erp/app/modules/items/ui/ChangeNotice/ChangeNoticeExplorer.tsx@@ -13,6 +13,7 @@ import {HStack,IconButton,MENU_ITEM_SHORTCUTS,+ PrefetchLink,useDisclosure,VStack} from "@carbon/react";@@ -142,9 +143,8 @@ function AffectedItemRow({return (<VStack spacing={0} className="border-b">- <Link+ <PrefetchLinkto={path.to.changeNoticeAffectedItem(changeOrderId, item.id)}- prefetch="intent"className="w-full"><HStack@@ -221,7 +221,7 @@ function AffectedItemRow({</div>)}</HStack>- </Link>+ </PrefetchLink></VStack>);}diff --git a/apps/erp/app/modules/items/ui/ChangeNotice/ItemLink.tsx b/apps/erp/app/modules/items/ui/ChangeNotice/ItemLink.tsxindex 1667cb2a11..3317e4cc97 100644--- a/apps/erp/app/modules/items/ui/ChangeNotice/ItemLink.tsx+++ b/apps/erp/app/modules/items/ui/ChangeNotice/ItemLink.tsx@@ -2,9 +2,8 @@// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,// including ports, remain AGPLv3; serving them over a network requires releasing their source.-import { cn } from "@carbon/react";+import { cn, PrefetchLink } from "@carbon/react";import type { ReactNode } from "react";-import { Link } from "react-router";import { getItemDetailPath } from "~/utils/path";// Renders an item reference (id/name) as a link to the item's detail page.@@ -24,12 +23,11 @@ export default function ItemLink({className?: string;}) {return (- <Link+ <PrefetchLinkto={getItemDetailPath(type, itemId)}- prefetch="intent"className={cn("hover:underline", className)}>{children}- </Link>+ </PrefetchLink>);}diff --git a/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx b/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsxindex 72006ebc11..70b6cdc78b 100644--- a/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx+++ b/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx@@ -35,6 +35,7 @@ import {ModalFooter,ModalHeader,ModalTitle,+ PrefetchLink,toast,useDisclosure,VStack@@ -257,9 +258,7 @@ const MakeMethodTools = ({</MenubarItem>{itemLink && (<MenubarItem leftIcon={<LuGitFork />} asChild>- <Link prefetch="intent" to={itemLink}>- Item Master- </Link>+ <PrefetchLink to={itemLink}>Item Master</PrefetchLink></MenubarItem>)}</HStack>diff --git a/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx b/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsxindex dc71392202..1617dcd52c 100644--- a/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx+++ b/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx@@ -24,6 +24,7 @@ import {ModalFooter,ModalHeader,ModalTitle,+ PrefetchLink,Tabs,TabsContent,TabsList,@@ -46,7 +47,7 @@ import {LuTriangleAlert} from "react-icons/lu";import { RiProgress4Line } from "react-icons/ri";-import { Link, useFetcher, useLocation, useParams } from "react-router";+import { useFetcher, useLocation, useParams } from "react-router";import { PrintButton } from "~/components";import { ConfiguratorModal } from "~/components/Configurator/ConfiguratorForm";import {@@ -357,9 +358,9 @@ const JobMakeMethodTools = ({ makeMethod }: { makeMethod?: JobMakeMethod }) => {)}{itemLink && (<MenubarItem leftIcon={<LuGitFork />} asChild>- <Link prefetch="intent" to={itemLink}>+ <PrefetchLink to={itemLink}><Trans>Item Master</Trans>- </Link>+ </PrefetchLink></MenubarItem>)}{makeMethod &&diff --git a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderExplorer.tsx b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderExplorer.tsxindex 6df6285938..c5ce6ac999 100644--- a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderExplorer.tsx+++ b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderExplorer.tsx@@ -13,6 +13,7 @@ import {HStack,IconButton,MENU_ITEM_SHORTCUTS,+ PrefetchLink,ShortcutKey,Tooltip,TooltipContent,@@ -336,9 +337,8 @@ function PurchaseOrderLineItem({return (<VStack spacing={0} className="border-b">- <Link+ <PrefetchLinkto={path.to.purchaseOrderLine(orderId, line.id!)}- prefetch="intent"className="w-full"><HStack@@ -437,7 +437,7 @@ function PurchaseOrderLineItem({</DropdownMenu></div></HStack>- </Link>+ </PrefetchLink>{receivingDisclosure.isOpen && (<Confirmaction={path.to.purchaseOrderLineReceiving(orderId, line.id!)}diff --git a/apps/erp/app/modules/purchasing/ui/PurchaseReturnOrders/PurchaseReturnOrderLineForm.tsx b/apps/erp/app/modules/purchasing/ui/PurchaseReturnOrders/PurchaseReturnOrderLineForm.tsxindex b1172a5aa5..1c7d1d1ba0 100644--- a/apps/erp/app/modules/purchasing/ui/PurchaseReturnOrders/PurchaseReturnOrderLineForm.tsx+++ b/apps/erp/app/modules/purchasing/ui/PurchaseReturnOrders/PurchaseReturnOrderLineForm.tsx@@ -22,6 +22,7 @@ import {ModalCardHeader,ModalCardProvider,ModalCardTitle,+ PrefetchLink,TrackedEntityPicker,toast,useDisclosure,@@ -37,7 +38,7 @@ import {LuLoaderCircle,LuX} from "react-icons/lu";-import { Link, useFetcher, useParams } from "react-router";+import { useFetcher, useParams } from "react-router";import type { z } from "zod";import {CustomFormFields,@@ -98,9 +99,8 @@ function SourceReference({value: string;}) {return (- <Link+ <PrefetchLinkto={to}- prefetch="intent"className="group inline-flex items-center gap-1.5 rounded-sm transition-colors hover:text-foreground"><span className="text-muted-foreground group-hover:text-foreground">@@ -109,7 +109,7 @@ function SourceReference({<span className="font-medium tabular-nums text-foreground/70 group-hover:text-foreground">{value}</span>- </Link>+ </PrefetchLink>);}diff --git a/apps/erp/app/modules/purchasing/ui/PurchasingRfq/PurchasingRFQExplorer.tsx b/apps/erp/app/modules/purchasing/ui/PurchasingRfq/PurchasingRFQExplorer.tsxindex f2d47be647..c94841d646 100644--- a/apps/erp/app/modules/purchasing/ui/PurchasingRfq/PurchasingRFQExplorer.tsx+++ b/apps/erp/app/modules/purchasing/ui/PurchasingRfq/PurchasingRFQExplorer.tsx@@ -13,6 +13,7 @@ import {HStack,IconButton,MENU_ITEM_SHORTCUTS,+ PrefetchLink,ShortcutKey,Tooltip,TooltipContent,@@ -267,9 +268,8 @@ function PurchasingRFQLineItem({return (<VStack spacing={0} className="border-b">- <Link+ <PrefetchLinkclassName="w-full"- prefetch="intent"to={path.to.purchasingRfqLine(rfqId, line.id!)}><HStack@@ -347,7 +347,7 @@ function PurchasingRFQLineItem({</DropdownMenu></div></HStack>- </Link>+ </PrefetchLink></VStack>);}diff --git a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteExplorer.tsx b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteExplorer.tsxindex d15ecadee3..c859a8d4f9 100644--- a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteExplorer.tsx+++ b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteExplorer.tsx@@ -13,6 +13,7 @@ import {HStack,IconButton,MENU_ITEM_SHORTCUTS,+ PrefetchLink,ShortcutKey,Tooltip,TooltipContent,@@ -288,9 +289,8 @@ function SupplierQuoteLineItem({return (<VStack spacing={0} className="border-b">- <Link+ <PrefetchLinkto={path.to.supplierQuoteLine(id, line.id!)}- prefetch="intent"className="w-full"><HStack@@ -371,7 +371,7 @@ function SupplierQuoteLineItem({</DropdownMenu></div></HStack>- </Link>+ </PrefetchLink></VStack>);}diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteMakeMethodTools.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteMakeMethodTools.tsxindex 82a98d4132..6fa003820f 100644--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteMakeMethodTools.tsx+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteMakeMethodTools.tsx@@ -24,6 +24,7 @@ import {ModalFooter,ModalHeader,ModalTitle,+ PrefetchLink,Tabs,TabsContent,TabsList,@@ -45,7 +46,7 @@ import {LuTriangleAlert} from "react-icons/lu";import { RiProgress4Line } from "react-icons/ri";-import { Link, useFetcher, useLocation, useParams } from "react-router";+import { useFetcher, useLocation, useParams } from "react-router";import { ConfiguratorModal } from "~/components/Configurator/ConfiguratorForm";import { Hidden, Item, Submit, useConfigurableItems } from "~/components/Form";import type { Tree } from "~/components/TreeView";@@ -282,9 +283,7 @@ const QuoteMakeMethodTools = () => {)}{itemLink && (<MenubarItem leftIcon={<LuGitFork />} asChild>- <Link prefetch="intent" to={itemLink}>- Item Master- </Link>+ <PrefetchLink to={itemLink}>Item Master</PrefetchLink></MenubarItem>)}</HStack>diff --git a/apps/erp/app/modules/sales/ui/SalesRFQ/SalesRFQExplorer.tsx b/apps/erp/app/modules/sales/ui/SalesRFQ/SalesRFQExplorer.tsxindex 92e6d6ea61..abe64f94ce 100644--- a/apps/erp/app/modules/sales/ui/SalesRFQ/SalesRFQExplorer.tsx+++ b/apps/erp/app/modules/sales/ui/SalesRFQ/SalesRFQExplorer.tsx@@ -16,6 +16,7 @@ import {HStack,IconButton,MENU_ITEM_SHORTCUTS,+ PrefetchLink,ShortcutKey,Spinner,Tooltip,@@ -34,7 +35,7 @@ import {LuSettings2,LuTrash} from "react-icons/lu";-import { Link, useFetchers, useParams } from "react-router";+import { useFetchers, useParams } from "react-router";import type { z } from "zod";import { Empty, ItemThumbnail } from "~/components";import type { DragHandleBindings } from "~/components/LineReorder";@@ -412,9 +413,8 @@ function SalesRFQLineItem({return (<VStack spacing={0} className="border-b">- <Link+ <PrefetchLinkclassName="w-full"- prefetch="intent"to={path.to.salesRfqLine(rfqId, line.id!)}><HStack@@ -467,7 +467,7 @@ function SalesRFQLineItem({</DropdownMenu></div></HStack>- </Link>+ </PrefetchLink></VStack>);}diff --git a/apps/erp/app/modules/sales/ui/SalesReturnOrders/SalesReturnOrderLineForm.tsx b/apps/erp/app/modules/sales/ui/SalesReturnOrders/SalesReturnOrderLineForm.tsxindex 323778ff4a..a4bc5a5452 100644--- a/apps/erp/app/modules/sales/ui/SalesReturnOrders/SalesReturnOrderLineForm.tsx+++ b/apps/erp/app/modules/sales/ui/SalesReturnOrders/SalesReturnOrderLineForm.tsx@@ -17,6 +17,7 @@ import {ModalCardHeader,ModalCardProvider,ModalCardTitle,+ PrefetchLink,SelectContent,SelectItem,SelectTrigger,@@ -28,7 +29,7 @@ import { INPUT_FORMAT, INPUT_STEP } from "@carbon/utils";import { Trans, useLingui } from "@lingui/react/macro";import { Fragment, useEffect, useState } from "react";import { LuCircleStop, LuLoaderCircle } from "react-icons/lu";-import { Link, useFetcher, useParams } from "react-router";+import { useFetcher, useParams } from "react-router";import type { z } from "zod";import {CustomFormFields,@@ -94,9 +95,8 @@ function SourceReference({}return (- <Link+ <PrefetchLinkto={to}- prefetch="intent"className="group inline-flex items-center gap-1.5 rounded-sm transition-colors hover:text-foreground"><span className="text-muted-foreground group-hover:text-foreground">@@ -105,7 +105,7 @@ function SourceReference({<span className="font-medium tabular-nums text-foreground/70 group-hover:text-foreground">{value}</span>- </Link>+ </PrefetchLink>);}diff --git a/apps/erp/app/modules/settings/ui/Integrations/SyncActivity.tsx b/apps/erp/app/modules/settings/ui/Integrations/SyncActivity.tsxindex df05c51963..854b0ff48b 100644--- a/apps/erp/app/modules/settings/ui/Integrations/SyncActivity.tsx+++ b/apps/erp/app/modules/settings/ui/Integrations/SyncActivity.tsx@@ -15,6 +15,7 @@ import {DrawerTitle,HStack,IconButton,+ PrefetchLink,Status,Table,Tbody,@@ -469,9 +470,8 @@ export function SyncActivity({{getEntityLabel(operation.entityType)}</span>{entityReference.path ? (- <Link+ <PrefetchLinkto={entityReference.path}- prefetch="intent"onClick={(e) => e.stopPropagation()}title={operation.entityId}className={cn(@@ -480,7 +480,7 @@ export function SyncActivity({)}>{entityReference.label}- </Link>+ </PrefetchLink>) : (<spantitle={operation.entityId}@@ -936,16 +936,15 @@ function SyncOperationDetailDrawer({<Detail label={t`Entity`}><div className="flex flex-col gap-0.5">{entityReference.path ? (- <Link+ <PrefetchLinkto={entityReference.path}- prefetch="intent"className={cn("break-all text-xs hover:underline",!entityReference.isReadable && "font-mono")}>{entityReference.label}- </Link>+ </PrefetchLink>) : (<spanclassName={cn(diff --git a/apps/erp/app/routes/onboarding+/company.tsx b/apps/erp/app/routes/onboarding+/company.tsxindex d3cd8fee32..e25b02f18c 100644--- a/apps/erp/app/routes/onboarding+/company.tsx+++ b/apps/erp/app/routes/onboarding+/company.tsx@@ -11,15 +11,11 @@ import {CardHeader,CardTitle,HStack,+ PrefetchLink,VStack} from "@carbon/react";import { getLocalTimeZone } from "@internationalized/date";-import {- type ActionFunctionArgs,- Link,- redirect,- useLoaderData-} from "react-router";+import { type ActionFunctionArgs, redirect, useLoaderData } from "react-router";import {OnboardingCard,OnboardingCardContent,@@ -135,9 +131,7 @@ export default function OnboardingCompany() {asChildtabIndex={-1}>- <Link to={previous} prefetch="intent">- Previous- </Link>+ <PrefetchLink to={previous}>Previous</PrefetchLink></Button><Submit shortcut={ONBOARDING_SHORTCUTS.continue}>Next</Submit></HStack>diff --git a/apps/erp/app/routes/onboarding+/industry.tsx b/apps/erp/app/routes/onboarding+/industry.tsxindex 8383b23525..8fd7b01c9c 100644--- a/apps/erp/app/routes/onboarding+/industry.tsx+++ b/apps/erp/app/routes/onboarding+/industry.tsx@@ -18,7 +18,8 @@ import {ChoiceCardGroup,type ChoiceCardOption,cn,- HStack+ HStack,+ PrefetchLink} from "@carbon/react";import { isInternalEmail } from "@carbon/utils";import { type ReactNode, useState } from "react";@@ -35,7 +36,6 @@ import {import {type ActionFunctionArgs,Form,- Link,redirect,useLoaderData,useNavigation@@ -419,9 +419,7 @@ export default function OnboardingIndustry() {asChildtabIndex={-1}>- <Link to={previous} prefetch="intent">- Previous- </Link>+ <PrefetchLink to={previous}>Previous</PrefetchLink></Button>{dataChoice === "none" ? (<Submit shortcut={ONBOARDING_SHORTCUTS.continue}>Next</Submit>diff --git a/apps/erp/app/routes/onboarding+/theme.tsx b/apps/erp/app/routes/onboarding+/theme.tsxindex 521e8a68d4..1da87ec69e 100644--- a/apps/erp/app/routes/onboarding+/theme.tsx+++ b/apps/erp/app/routes/onboarding+/theme.tsx@@ -12,6 +12,7 @@ import {CardTitle,cn,HStack,+ PrefetchLink,RadioGroup,RadioGroupButton,useMode,@@ -26,7 +27,6 @@ import { BiMoon, BiSun } from "react-icons/bi";import { RxCheck } from "react-icons/rx";import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";import {- Link,redirect,useFetcher,useLoaderData,@@ -224,9 +224,9 @@ export default function OnboardingTheme() {asChildtabIndex={-1}>- <Link to={previous} prefetch="intent">+ <PrefetchLink to={previous}><Trans>Previous</Trans>- </Link>+ </PrefetchLink></Button>)}diff --git a/apps/erp/app/routes/onboarding+/user.tsx b/apps/erp/app/routes/onboarding+/user.tsxindex 95189343ad..bf1360ffa7 100644--- a/apps/erp/app/routes/onboarding+/user.tsx+++ b/apps/erp/app/routes/onboarding+/user.tsx@@ -14,11 +14,12 @@ import {CardHeader,CardTitle,HStack,+ PrefetchLink,VStack} from "@carbon/react";import { Trans, useLingui } from "@lingui/react/macro";import type { ActionFunctionArgs } from "react-router";-import { Link, redirect, useLoaderData } from "react-router";+import { redirect, useLoaderData } from "react-router";import type { z } from "zod";import {OnboardingCard,@@ -134,9 +135,9 @@ export default function OnboardingUser() {asChildtabIndex={-1}>- <Link to={previous} prefetch="intent">+ <PrefetchLink to={previous}><Trans>Previous</Trans>- </Link>+ </PrefetchLink></Button><Submit shortcut={ONBOARDING_SHORTCUTS.continue}><Trans>Next</Trans>diff --git a/apps/erp/app/routes/x+/_index.tsx b/apps/erp/app/routes/x+/_index.tsxindex 17b221e7ba..f10a85da2b 100644--- a/apps/erp/app/routes/x+/_index.tsx+++ b/apps/erp/app/routes/x+/_index.tsx@@ -21,6 +21,7 @@ import {CardContent,cn,IconButton,+ PrefetchLink,Skeleton,Tooltip,TooltipContent,@@ -137,9 +138,7 @@ function ImplementationSummary({ data }: { data: ImplementationHubData }) {onDismiss={dismiss}action={<Button asChild>- <Link to={path.to.getStarted} prefetch="intent">- Open- </Link>+ <PrefetchLink to={path.to.getStarted}>Open</PrefetchLink></Button>}/>@@ -469,9 +468,8 @@ const RecentDocumentRow = ({const { locale } = useLocale();return (<div className="relative group">- <Link+ <PrefetchLinkto={doc.url}- prefetch="intent"className="flex items-center gap-3 p-3 bg-muted/20 rounded-lg border border-border hover:border-foreground/20 transition-colors"><div className="shrink-0 w-9 h-9 rounded-lg flex items-center justify-center bg-muted">@@ -486,7 +484,7 @@ const RecentDocumentRow = ({{formatRelativeTime(doc.viewedAt, locale)}</div></div>- </Link>+ </PrefetchLink><IconButtonaria-label={t`Remove`}icon={<LuX />}@@ -499,20 +497,22 @@ const RecentDocumentRow = ({);};-const ModuleCard = ({ module }: { module: Authenticated<NavItem> }) => (- <Link- to={module.to}- prefetch={module.external ? "none" : "intent"}- {...(module.external- ? { target: "_blank", rel: "noopener noreferrer" }- : {})}- className="flex items-center gap-4 p-4 rounded-lg border border-border group bg-muted/20 hover:border-foreground/20 cursor-pointer transition-colors duration-200"- >- <div className="shrink-0 p-2.5 rounded-lg border border-border group-hover:border-foreground/20 transition-colors">- <module.icon className="text-xl" />- </div>- <span className="text-sm py-1 px-4 border border-border rounded-full group-hover:bg-background font-medium tracking-tight transition-colors">- {module.name}- </span>- </Link>-);+const ModuleCard = ({ module }: { module: Authenticated<NavItem> }) => {+ const Anchor = module.external ? Link : PrefetchLink;+ return (+ <Anchor+ to={module.to}+ {...(module.external+ ? { target: "_blank", rel: "noopener noreferrer" }+ : {})}+ className="flex items-center gap-4 p-4 rounded-lg border border-border group bg-muted/20 hover:border-foreground/20 cursor-pointer transition-colors duration-200"+ >+ <div className="shrink-0 p-2.5 rounded-lg border border-border group-hover:border-foreground/20 transition-colors">+ <module.icon className="text-xl" />+ </div>+ <span className="text-sm py-1 px-4 border border-border rounded-full group-hover:bg-background font-medium tracking-tight transition-colors">+ {module.name}+ </span>+ </Anchor>+ );+};diff --git a/apps/erp/app/routes/x+/accounting+/reports.tsx b/apps/erp/app/routes/x+/accounting+/reports.tsxindex 92e2d5de45..1e28f699cf 100644--- a/apps/erp/app/routes/x+/accounting+/reports.tsx+++ b/apps/erp/app/routes/x+/accounting+/reports.tsx@@ -14,6 +14,7 @@ import {Input,InputGroup,InputLeftElement,+ PrefetchLink,Subheading} from "@carbon/react";import { msg } from "@lingui/core/macro";@@ -43,7 +44,7 @@ import type {LoaderFunctionArgs,MetaFunction} from "react-router";-import { data, Link, useFetcher, useLoaderData } from "react-router";+import { data, useFetcher, useLoaderData } from "react-router";import ConfirmDelete from "~/components/Modals/ConfirmDelete";import {getReportPins,@@ -389,10 +390,9 @@ export default function ReportsIndexRoute() {<SectionHeading>{category}</SectionHeading><div className="overflow-hidden rounded-lg border border-border">{categoryReports.map((report, index) => (- <Link+ <PrefetchLinkkey={report.key}to={report.to}- prefetch="intent"className={"flex cursor-pointer items-center gap-3 bg-card/70 px-4 py-2.5 transition-colors hover:bg-accent/40" +(index > 0 ? " border-t border-border" : "")@@ -411,7 +411,7 @@ export default function ReportsIndexRoute() {pinLabel={t`Pin ${report.name}`}/></span>- </Link>+ </PrefetchLink>))}</div></div>@@ -423,10 +423,9 @@ export default function ReportsIndexRoute() {</SectionHeading><div className="overflow-hidden rounded-lg border border-border">{categoryViews.map((view, index) => (- <Link+ <PrefetchLinkkey={view.id}to={`${path.to.analyticsReport(view.reportKey)}?view=${view.id}`}- prefetch="intent"className={"flex cursor-pointer items-center gap-3 bg-card/70 px-4 py-2.5 transition-colors hover:bg-accent/40" +(index > 0 ? " border-t border-border" : "")@@ -468,7 +467,7 @@ export default function ReportsIndexRoute() {/>)}</span>- </Link>+ </PrefetchLink>))}</div></div>@@ -514,9 +513,8 @@ const PinnedCard = ({pinLabel: string;unpinLabel: string;}) => (- <Link+ <PrefetchLinkto={to}- prefetch="intent"className="group flex cursor-pointer items-center justify-between gap-4 rounded-lg border border-border bg-card/70 p-4 backdrop-blur-md transition-colors duration-200 hover:border-foreground/20 hover:bg-accent/40"><span className="flex items-center gap-3 overflow-hidden">@@ -533,7 +531,7 @@ const PinnedCard = ({pinLabel={pinLabel}unpinLabel={unpinLabel}/>- </Link>+ </PrefetchLink>);// Sits inside the card/row Link, so it must not trigger navigation. Pinneddiff --git a/apps/mes/app/components/Hyperlink.tsx b/apps/mes/app/components/Hyperlink.tsxindex fa71fb3105..dc92b74597 100644--- a/apps/mes/app/components/Hyperlink.tsx+++ b/apps/mes/app/components/Hyperlink.tsx@@ -2,10 +2,9 @@// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,// including ports, remain AGPLv3; serving them over a network requires releasing their source.-import { cn } from "@carbon/react";+import { cn, PrefetchLink } from "@carbon/react";import type { ComponentProps, PropsWithChildren } from "react";import type { LinkProps } from "react-router";-import { Link } from "react-router";const Hyperlink = ({children,@@ -15,8 +14,7 @@ const Hyperlink = ({| PropsWithChildren<LinkProps>| PropsWithChildren<ComponentProps<"span">>) => {return "to" in props && props.to ? (- <Link- prefetch="intent"+ <PrefetchLinkclassName={cn("text-foreground hover:underline cursor-pointer font-medium",className@@ -24,7 +22,7 @@ const Hyperlink = ({{...props}>{children}- </Link>+ </PrefetchLink>) : (<spanclassName={cn(diff --git a/apps/starter/app/components/Breadcrumbs.tsx b/apps/starter/app/components/Breadcrumbs.tsxindex acc8be14ec..504242f041 100644--- a/apps/starter/app/components/Breadcrumbs.tsx+++ b/apps/starter/app/components/Breadcrumbs.tsx@@ -17,6 +17,7 @@ import {DropdownMenuTrigger,getValidChildren,HStack,+ PrefetchLink,ScrollArea,useIsMobile,useMode@@ -25,7 +26,7 @@ import type { ComponentProps } from "react";import { cloneElement, forwardRef, useMemo } from "react";import { LuChevronsUpDown } from "react-icons/lu";import type { LinkProps } from "react-router";-import { Form, Link, useMatches } from "react-router";+import { Form, useMatches } from "react-router";import { z } from "zod";import { useRouteData } from "~/hooks";import { path } from "~/utils/path";@@ -95,9 +96,9 @@ const BreadcrumbLink = forwardRef<{children}</span>) : (- <Link ref={ref} {...props} prefetch="intent">+ <PrefetchLink ref={ref} {...props}>{children}- </Link>+ </PrefetchLink>)}</Button>);diff --git a/packages/react/AGENTS.md b/packages/react/AGENTS.mdindex fe72cb07d8..f3742409e0 100644--- a/packages/react/AGENTS.md+++ b/packages/react/AGENTS.md@@ -42,6 +42,7 @@ import { Button, Card, HStack, VStack, IconButton, cn } from "@carbon/react";- **Layout**: `VStack` / `HStack` with numeric `spacing` prop (maps to `space-y-*`/`space-x-*`)- **Overlays**: `Drawer`, `Modal`, `ModalDrawer` (unified drawer/modal), `BottomSheet`, `Popover`- **App nav**: `NavRail` is the primary left nav of both the ERP and MES shells (56px icon rail, expands after a 150ms mouse hover or when pinned via `SidebarProvider` (⌘B unless `keyboardShortcut={false}`, as in the ERP), left drawer below md that closes itself on navigation). Optional `header` (use `NavRailBrand` for a logo + name) and `footer` slots; `NavRailGroup` adds a titled section that shows as a divider while collapsed. Entries are `NavRailItem` (a button, or `asChild` for a trigger/link) and `NavRailLink`; `label` is a string and doubles as the accessible name. A Radix menu/popover opened from a `NavRailItem` keeps the rail as it was (open or collapsed) until it closes. Render inside `SidebarProvider`; the shadcn-style `Sidebar*` primitives remain for other layouts+- **Links that prefetch**: `PrefetchLink` is a React Router `Link` that prefetches its destination when the pointer goes down on it. Use it instead of `<Link prefetch="intent">`, which prefetches on a 100 ms hover and so runs a page's loaders for every row the mouse passes over. `NavRailLink` and both apps' `Hyperlink` already use it- **Data**: `Table` (TanStack), chart components via sub-exports (`@carbon/react/Chart`)- **Rich text**: `@carbon/react/Editor` and `@carbon/react/RichText` (wraps `@carbon/tiptap`)- **Error boundary**: `@carbon/react/ErrorBoundary` — `RootErrorBoundary` (drop-in root `ErrorBoundary` for RR v7 that maps 404 / other HTTP / thrown `Error` to a styled screen) plus its parts (`ErrorScreen`, `GlitchHeading`, `StatusReadout`, `MagneticLink`, `NoiseOverlay`). Wrap it in the app's `Document` and pass `env` so `window.env` is set (the client crashes hydration otherwise). Copy is intentionally hardcoded English, not i18n.diff --git a/packages/react/src/NavRail.tsx b/packages/react/src/NavRail.tsxindex 0b177ee383..a4d2f781fc 100644--- a/packages/react/src/NavRail.tsx+++ b/packages/react/src/NavRail.tsx@@ -19,6 +19,7 @@ import {import type { LinkProps } from "react-router";import { Link, useLocation } from "react-router";import { Drawer, DrawerContent, DrawerTitle } from "./Drawer";+import { PrefetchLink } from "./PrefetchLink";import { Separator } from "./Separator";import { useSidebar } from "./Sidebar";import { cn } from "./utils/cn";@@ -387,6 +388,7 @@ export function NavRailLink({target?: LinkProps["target"];rel?: string;}) {+ const Anchor = external ? Link : PrefetchLink;return (<NavRailItemasChild@@ -396,12 +398,11 @@ export function NavRailLink({tag={tag}trailing={trailing}>- <Link+ <Anchorto={to}target={target}rel={rel}aria-current={isActive ? "page" : undefined}- prefetch={external ? "none" : "intent"}/></NavRailItem>);diff --git a/packages/react/src/PrefetchLink.tsx b/packages/react/src/PrefetchLink.tsxnew file mode 100644index 0000000000..a6228e193c--- /dev/null+++ b/packages/react/src/PrefetchLink.tsx@@ -0,0 +1,58 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,+// including ports, remain AGPLv3; serving them over a network requires releasing their source.++"use client";++import { forwardRef, useState } from "react";+import type { LinkProps } from "react-router";+import { Link, PrefetchPageLinks, useHref } from "react-router";++const ABSOLUTE_URL = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;++/**+ * A `Link` that prefetches its destination when the pointer goes down on it.+ *+ * `prefetch="intent"` prefetches on a 100 ms hover, so moving the mouse down a+ * list ran every hovered page's loaders for a click that mostly never came. A+ * press is a commitment: it costs one request, and the page gets the time+ * between press and release as a head start. Chromium serves the click from+ * the prefetched response; a browser that does not reuse it makes one extra+ * request per click, never one per hover.+ *+ * Use this instead of `<Link prefetch="intent">`.+ */+export const PrefetchLink = forwardRef<+ HTMLAnchorElement,+ Omit<LinkProps, "prefetch">+>(({ onPointerDown, ...props }, ref) => {+ const href = useHref(props.to, { relative: props.relative });+ // A new key remounts the prefetch tags, so each press prefetches again.+ const [presses, setPresses] = useState(0);+ const canPrefetch =+ props.to !== "#" &&+ !(typeof props.to === "string" && ABSOLUTE_URL.test(props.to));++ return (+ <>+ <Link+ ref={ref}+ {...props}+ onPointerDown={(event) => {+ onPointerDown?.(event);+ // A modified or non-primary press opens a new tab or a menu: the+ // page being prefetched would not be the one that uses it.+ const plain =+ event.button === 0 &&+ !event.metaKey &&+ !event.ctrlKey &&+ !event.shiftKey &&+ !event.altKey;+ if (plain && canPrefetch) setPresses((n) => n + 1);+ }}+ />+ {presses > 0 && <PrefetchPageLinks key={presses} page={href} />}+ </>+ );+});+PrefetchLink.displayName = "PrefetchLink";diff --git a/packages/react/src/index.tsx b/packages/react/src/index.tsxindex 05affc4403..1159ff677c 100644--- a/packages/react/src/index.tsx+++ b/packages/react/src/index.tsx@@ -277,6 +277,7 @@ import {PopoverHeader,PopoverTrigger} from "./Popover";+import { PrefetchLink } from "./PrefetchLink";import { Progress } from "./Progress";import { PulsingDot } from "./PulsingDot";import { RadioGroup, RadioGroupButton, RadioGroupItem } from "./Radio";@@ -581,6 +582,7 @@ export {PopoverFooter,PopoverHeader,PopoverTrigger,+ PrefetchLink,Progress,PulsingDot,RadioGroup,