{"id":19846678,"url":"https://github.com/chempogonzalez/next-active-link","last_synced_at":"2026-05-17T02:13:53.550Z","repository":{"id":57687719,"uuid":"487670844","full_name":"chempogonzalez/next-active-link","owner":"chempogonzalez","description":"✅ Active link component for Next.JS, wrapping next/link component","archived":false,"fork":false,"pushed_at":"2022-05-08T03:04:34.000Z","size":218,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-11T15:49:48.238Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chempogonzalez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-02T00:06:43.000Z","updated_at":"2022-05-06T01:56:35.000Z","dependencies_parsed_at":"2022-08-25T17:53:54.491Z","dependency_job_id":null,"html_url":"https://github.com/chempogonzalez/next-active-link","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chempogonzalez%2Fnext-active-link","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chempogonzalez%2Fnext-active-link/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chempogonzalez%2Fnext-active-link/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chempogonzalez%2Fnext-active-link/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chempogonzalez","download_url":"https://codeload.github.com/chempogonzalez/next-active-link/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241225445,"owners_count":19930184,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T13:12:09.658Z","updated_at":"2026-05-17T02:13:48.521Z","avatar_url":"https://github.com/chempogonzalez.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ✅ next-active-link [![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)\n\u003cimg src=\"https://img.shields.io/npm/v/next-active-link?style=for-the-badge\" /\u003e\n\n\u003e Active link component for Next.JS\n\n## 🔖 Description\n`next/link` wrapper which automatically add the provided class to the link element.\n\n## 📦 Installation\n```zsh\n# Install the component\n$ npm install next-active-link\n```\n\n## 🚀 Usage\nThe usage is the same as the `next/link` component. More information in [Official docs](https://nextjs.org/docs/api-reference/next/link)\n\nThe differences are that the _**next-active-link**_ component has the following props `activeClassName` and `activeMatchOptions` .\n\n### 🟢 ActiveClassName\n_(Component prop)_ The class name to be added to the link element when the link is active.\n```ts\nconst activeClassName: string = 'active-link'\n```\n\n### 🟢 ActiveMatchOptions\n_(Component prop)_ The options to be used to match the link.\n```ts\n/**\n *  You have the following options:\n */\n  const activeMatchOptions_Option_1 = {\n    exact: true | false\n  }\n\n  const activeMatchOptions_Option_2 = {\n    paths: 'exact' | 'partial'        // optional\n    queryParams: 'exact' | 'partial'  // optional\n    fragment: 'exact'                 // optional\n  }\n```\n\n### 🟢 onActiveChange\n_(Component `method` prop)_ The callback to be called when the link active state changes.\n```ts\n  const onActiveChange: (isActive: boolean) =\u003e {\n    // ...\n  }\n```\n\n## 🤓 Example\n```tsx\nimport { ActiveLink } from 'next-active-link';\n\n  function MyPage() {\n  /**\n   * Adds 'active-link' className to \"a\" tag\n   * if the current page is '/contact'\n  */\n  return (\n    \u003cActiveLink\n      href=\"/contact\"\n      activeClassName=\"active-link\"\n      onActiveChange={(isActive) =\u003e console.log(isActive)}\n      {/* Default options */}\n      activeMatchOptions={{\n        exact: true\n      }}\n    \u003e\n      \u003ca\u003eContact\u003c/a\u003e\n    \u003c/ActiveLink\u003e\n  )\n\n\n  /** ------------------------------------------------------ */\n\n  function MyPage() {\n  /**\n   * Adds 'active-link' className to \"a\" tag\n   * if the current page is '/any-page?name=Chempo'\n   * (has the exact query params)\n  */\n  return (\n    \u003cActiveLink\n      href=\"/contact?name=Chempo\"\n      activeClassName=\"active-link\"\n      onActiveChange={(isActive) =\u003e console.log(isActive)}\n      activeMatchOptions={{\n        queryParams: 'exact'\n      }}\n    \u003e\n      \u003ca\u003eContact\u003c/a\u003e\n    \u003c/ActiveLink\u003e\n  )\n}\n```\n\n## 🤓 Happy Code\n\n\u003e Created with Typescript! ⚡ and latin music 🎺🎵\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchempogonzalez%2Fnext-active-link","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchempogonzalez%2Fnext-active-link","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchempogonzalez%2Fnext-active-link/lists"}