Next.js link

Next.js link is a neobrutalist React component from Cruise UI. next/link wrapped in a "use client" file, for the linkComponent prop of the Dashboard layout, Footer, Auth card and Dropdown menu, so their links navigate client-side. Works when passed from a Server Component, which next/link's Link itself can't be. Install it with npx shadcn@latest add @cruiseui/cruise-next-link.

Install

Terminal

npx shadcn@latest add @cruiseui/cruise-next-link

First time? Installation shows the one-off components.json setup (the @cruiseui registry) and how to turn the theme on.

Example

Corners

Pass it as linkComponent and the block's links navigate client-side, with no full page reload. Passing next/link's Link itself from a Server Component fails; this wrapper works there and in client components.

tsx
// app/dashboard/layout.tsx (a Server Component)
import { CruiseDashboardLayout } from "@/components/cruise/blocks/dashboard-layout";
import { CruiseNextLink } from "@/components/cruise/next-link";

export default function DashboardLayout({ children }: { children: React.ReactNode }) {
  return (
    <CruiseDashboardLayout
      brand="Kiosk"
      logoHref="/dashboard"
      linkComponent={CruiseNextLink}
      nav={[
        { label: "Overview", href: "/dashboard" },
        { label: "Orders", href: "/dashboard/orders" },
      ]}
    >
      {children}
    </CruiseDashboardLayout>
  );
}

When to use it

When to use

A Next.js app using the Dashboard layout, Footer, Auth card or Dropdown menu.

When not to

Other frameworks: pass your router's link component (or leave the default <a>).

Props

CruiseNextLink

No props.

Usage

  • `<CruiseDashboardLayout linkComponent={CruiseNextLink} … />` in app/<section>/layout.tsx. Passing `Link` from next/link directly fails in a Server Component ("Functions cannot be passed directly to Client Components"); this wrapper is a client reference, so it works there and in client components.
  • It takes every next/link prop (prefetch, replace, scroll…).

Accessibility

  • Renders a real <a> with an href, like next/link.