npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@nuraloom/navlink

v1.0.4

Published

A production-ready NavLink component for Next.js (App Router)

Readme

🧭 NavLink — Smart Active Link Component for Next.js (App Router)

A production-ready NavLink component for Next.js App Router. It simplifies building navigation with active link highlighting, SSR-safe active detection, and external link handling — all fully typed with TypeScript.


✨ Features

✅ Seamless integration with Next.js App Router (usePathname) ✅ Automatic active link detection (exact or partial match) ✅ Safe external link handling with proper security defaults ✅ Fully typed with NavLinkProps ✅ Built-in accessibility (aria-current="page") ✅ SSR-safe — avoids hydration mismatches ✅ Minimal and performance-optimized (uses useMemo for all derived states)


📦 Installation

npm install @your-org/navlink
# or
yarn add @your-org/navlink

🚀 Usage

"use client";

import NavLink from "@your-org/navlink";

export default function Navbar() {
  return (
    <nav className="flex gap-4">
      <NavLink href="/" exact>
        Home
      </NavLink>
      <NavLink href="/about">About</NavLink>
      <NavLink href="https://example.com" target="_blank">
        External Site
      </NavLink>
    </nav>
  );
}

Active Link Example

  • When on /about, the “About” link automatically gets activeClassName.
  • For /about/team, it also highlights /about unless you set exact.

⚙️ Props

| Prop | Type | Default | Description | | ----------------- | ----------------- | --------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | | href | string | required | Destination URL (internal or external). | | exact | boolean | false | Require exact match to mark as active. | | activeClassName | string | "text-sky-600 font-semibold bg-sky-50 dark:bg-sky-950/20" | Classes applied when active. | | className | string | "inline-flex items-center gap-2 px-3 py-2 rounded-md transition-colors duration-200 focus:outline-none" | Base classes for the link. | | children | React.ReactNode | — | Link label or content. | | [...rest] | HTML anchor props | — | All other anchor attributes (target, rel, etc.). |


🧠 Active State Logic

The component:

  • Uses usePathname() from next/navigation.
  • Normalizes paths (/about//about).
  • Supports exact or startsWith match.
  • Avoids hydration mismatches during SSR.

🌐 External Link Handling

Automatically detects external URLs (https://, http://) and applies correct handling. You can still override target="_blank" or rel="noopener noreferrer" manually if needed.


🧩 Type Exports

If you need strong typing in your project:

import type { NavLinkProps } from "@your-org/navlink";

🔍 Example Styling

You can customize styles easily with Tailwind or CSS:

<NavLink
  href="/dashboard"
  className="px-4 py-2 text-gray-700 hover:text-sky-600"
  activeClassName="font-bold text-sky-600 border-b-2 border-sky-600"
>
  Dashboard
</NavLink>

🧱 Folder Structure

src/
├── NavLink.tsx
└── index.ts

index.ts

export { default } from "./NavLink";
export type { NavLinkProps } from "./NavLink";

📜 License

MIT © 2025 NuraLoom