{"_id":"@aref-shojaei/router","_rev":"8-73298936cb48e50262c8856b15a1ce13","name":"@aref-shojaei/router","dist-tags":{"latest":"1.3.0"},"versions":{"1.0.1":{"name":"@aref-shojaei/router","version":"1.0.1","keywords":["router","routing","route","spa"],"author":{"name":"Aref Shojaei"},"license":"MIT","_id":"@aref-shojaei/router@1.0.1","maintainers":[{"name":"aref-shojaei","email":"arefshojaei82dev@gmail.com"}],"homepage":"https://github.com/ArefShojaei/Router#readme","bugs":{"url":"https://github.com/ArefShojaei/Router/issues"},"dist":{"shasum":"b9c47e1a6feaea9dcd9fec47b4acc3b184388b28","tarball":"https://registry.npmjs.org/@aref-shojaei/router/-/router-1.0.1.tgz","fileCount":36,"integrity":"sha512-/omCdSEnJj9RF0MIDdFTpwzV4GnsRrZAzkC29RxgTzk54VgchPN4p+s+KI+4D/IGDNxAWVCEs6m+2rngoO1izw==","signatures":[{"sig":"MEYCIQCLZMZ2SuAmjGCyn7Vwy8V5Y91ISoqDNfpm/QIBo5Bi/AIhAJ7d4SbtSCh1Peo0vmxgO37ZAop6MO0JZmRvCxAW7SUm","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":41360},"jest":{"transform":{"^.+\\.js$":"babel-jest"}},"main":"index.js","scripts":{"test":"jest"},"_npmUser":{"name":"aref-shojaei","email":"arefshojaei82dev@gmail.com"},"repository":{"url":"git+https://github.com/ArefShojaei/Router.git","type":"git"},"description":"JavaScript Router (SPA)","directories":{},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","jsdom":"^25.0.1","babel-jest":"^29.7.0","@babel/core":"^7.26.0","@babel/preset-env":"^7.26.0"},"_npmOperationalInternal":{"tmp":"tmp/router_1.0.1_1735907760320_0.16069719216367817","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@aref-shojaei/router","version":"1.0.2","keywords":["router","routing","route","spa"],"author":{"name":"Aref Shojaei"},"license":"MIT","_id":"@aref-shojaei/router@1.0.2","maintainers":[{"name":"aref-shojaei","email":"arefshojaei82dev@gmail.com"}],"homepage":"https://github.com/ArefShojaei/Router#readme","bugs":{"url":"https://github.com/ArefShojaei/Router/issues"},"dist":{"shasum":"2525053e9ea14aa62540768107d1d59e3bb07eb8","tarball":"https://registry.npmjs.org/@aref-shojaei/router/-/router-1.0.2.tgz","fileCount":36,"integrity":"sha512-I3FUvO3Kemw2ooZSl/vyjFUOK33yLpnvRD5EiZKc8334fMF+wTXxAqwTHMV+X2eoPykF18wE8L/p2gmF2+7XTw==","signatures":[{"sig":"MEUCIQDF/HY0bvby+kWTYH7yKUx30rePnhUCL0Qe9rzreOoyewIgF6sXlvjnvak2pD+srHxFQFn+6wI5baAEyb9F22c0AXg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":41306},"jest":{"transform":{"^.+\\.js$":"babel-jest"}},"main":"index.js","scripts":{"test":"jest"},"_npmUser":{"name":"aref-shojaei","actor":{"name":"aref-shojaei","type":"user","email":"arefshojaei82dev@gmail.com"},"email":"arefshojaei82dev@gmail.com"},"repository":{"url":"git+https://github.com/ArefShojaei/Router.git","type":"git"},"description":"JavaScript Router (SPA)","directories":{},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","jsdom":"^25.0.1","babel-jest":"^29.7.0","@babel/core":"^7.26.0","@babel/preset-env":"^7.26.0"},"_npmOperationalInternal":{"tmp":"tmp/router_1.0.2_1751625348965_0.8666311167471796","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@aref-shojaei/router","version":"1.1.0","keywords":["router","routing","route","spa"],"author":{"name":"Aref Shojaei"},"license":"MIT","_id":"@aref-shojaei/router@1.1.0","maintainers":[{"name":"aref-shojaei","email":"arefshojaei82@gmail.com"}],"homepage":"https://github.com/ArefShojaei/Router#readme","bugs":{"url":"https://github.com/ArefShojaei/Router/issues"},"dist":{"shasum":"2e70d15dc3bef75b89915ea3465db4c2ce022ea0","tarball":"https://registry.npmjs.org/@aref-shojaei/router/-/router-1.1.0.tgz","fileCount":25,"integrity":"sha512-GTVhot2hYrWLV7lE3X1BVcWqhMRD18TUFaZFvr+y53GgZUSHhuF3nNsR2mgwWSkhYHXHG32MZ3NmPq7NZvN14A==","signatures":[{"sig":"MEUCIQDa83/4D/B+zlFAnlyOb3rVq6dJ1KHyZM8dLRoTNV6jZgIgeXaEbCuV1r3CKM/L9xOMfzO0M69VO8Y61iIHDtEVXpg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":55751},"jest":{"transform":{"^.+\\.js$":"babel-jest"}},"main":"index.js","gitHead":"cf6245c589c2bfb2388a657afb08f0cb21839e18","scripts":{"test":"jest","build":"webpack --mode=production","watch":"webpack --watch --mode=development"},"_npmUser":{"name":"aref-shojaei","email":"arefshojaei82@gmail.com"},"repository":{"url":"git+https://github.com/ArefShojaei/Router.git","type":"git"},"_npmVersion":"10.8.2","description":"JavaScript Routing for Front-end (SPA)","directories":{"src":"src","test":"tests","build":"build","example":"example"},"_nodeVersion":"18.20.8","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","jsdom":"^25.0.1","webpack":"^5.105.1","@babel/cli":"^7.28.6","babel-jest":"^29.7.0","@babel/core":"^7.26.0","webpack-cli":"^6.0.1","babel-loader":"^10.0.0","@babel/preset-env":"^7.26.0"},"_npmOperationalInternal":{"tmp":"tmp/router_1.1.0_1781632468743_0.4708677503681389","host":"s3://npm-registry-packages-npm-production"}},"1.3.0":{"name":"@aref-shojaei/router","version":"1.3.0","description":"JavaScript Routing for Front-end (SPA)","main":"index.js","directories":{"test":"tests","src":"src","build":"build","example":"example"},"scripts":{"build":"webpack --mode=production","watch":"webpack --watch --mode=development","test":"jest","lint":"eslint src tests","format":"prettier src tests --write","format:check":"prettier src tests --check"},"repository":{"type":"git","url":"git+https://github.com/ArefShojaei/Router.git"},"keywords":["router","routing","route","spa"],"author":{"name":"Aref Shojaei"},"license":"MIT","bugs":{"url":"https://github.com/ArefShojaei/Router/issues"},"homepage":"https://github.com/ArefShojaei/Router#readme","devDependencies":{"@babel/cli":"^7.28.6","@babel/core":"^7.26.0","@babel/preset-env":"^7.26.0","@eslint/js":"^9.39.5","babel-jest":"^29.7.0","babel-loader":"^10.0.0","eslint":"^9.39.5","eslint-config-prettier":"^10.1.8","jest":"^29.7.0","jsdom":"^25.0.1","prettier":"^3.9.6","webpack":"^5.105.1","webpack-cli":"^6.0.1"},"_id":"@aref-shojaei/router@1.3.0","gitHead":"fd947a799cae1d300d110176d2968e809ccf556d","_nodeVersion":"18.20.8","_npmVersion":"10.8.2","dist":{"integrity":"sha512-o5kzcpzaD+N7dCbvBfqEgWBQjb9Pl8Y0ueBx84N9JIIU4RP+1l5aeoPM8SGqUkqQ1EUX0wLl7wRORijOqpxWsw==","shasum":"847c53445c7e12e30e0b7aae44913be2d11fdff1","tarball":"https://registry.npmjs.org/@aref-shojaei/router/-/router-1.3.0.tgz","fileCount":25,"unpackedSize":59979,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHdT5Q69N1NkqXg4uJnYN8NUlXHUvBzNz5KJi4KJQzfwAiEA0wfthq2zQTZ8+fK3lvtTNlX0A1KCx1rwTwRwuVTGA1I="}]},"_npmUser":{"name":"aref-shojaei","email":"arefshojaei82@gmail.com"},"maintainers":[{"name":"aref-shojaei","email":"arefshojaei82@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/router_1.3.0_1786562007390_0.9584105348662086"},"_hasShrinkwrap":false}},"time":{"created":"2025-01-03T12:36:00.209Z","modified":"2026-08-12T19:13:27.729Z","1.0.0":"2024-12-24T15:45:58.398Z","2.0.0":"2024-12-25T08:55:49.676Z","1.0.1":"2025-01-03T12:36:00.574Z","1.0.2":"2025-07-04T10:35:49.144Z","1.1.0":"2026-06-16T17:54:28.885Z","1.3.0":"2026-08-12T19:13:27.566Z"},"bugs":{"url":"https://github.com/ArefShojaei/Router/issues"},"author":{"name":"Aref Shojaei"},"license":"MIT","homepage":"https://github.com/ArefShojaei/Router#readme","keywords":["router","routing","route","spa"],"repository":{"type":"git","url":"git+https://github.com/ArefShojaei/Router.git"},"description":"JavaScript Routing for Front-end (SPA)","maintainers":[{"name":"aref-shojaei","email":"arefshojaei82@gmail.com"}],"readme":"<div align=\"center\">\n\n# 🚀 Router - Lightweight JavaScript SPA Router\n\nA lightweight and powerful client-side routing library for building Single Page Applications (SPA) with pure JavaScript.\n\nDefine routes, manage navigation, handle dynamic parameters, apply middleware, and create seamless page transitions without refreshing the browser.\n\n<img src=\"https://github.com/user-attachments/assets/f1831dc5-f72e-4d7a-806d-b9c01b4be29a\" alt=\"Router SPA Banner\" />\n\n</div>\n\n---\n\n## ✨ Features\n\n- 🚀 Client-side SPA routing\n- 🔗 Browser History API support\n- 📄 Single and grouped routes\n- 🔥 Dynamic route parameters\n- 🛡 Route middleware system\n- 🔀 Route redirection\n- 🏷 Dynamic page titles\n- ⚡ No page refresh navigation\n- 🪶 Lightweight and dependency-free\n- 🧩 Simple and expressive API\n\n---\n\n# 📦 Installation\n\n## Using NPM\n\n```bash\nnpm install @aref-shojaei/router\n```\n\n## Using Yarn\n\n```bash\nyarn add @aref-shojaei/router\n```\n\n---\n\n# 🚀 Quick Start\n\nCreate your `app.js` file:\n\n```javascript\nimport { Router, Route } from \"@aref-shojaei/router\";\n\n// Configure browser environment\nRouter.configure({\n\twindow,\n\tdocument,\n});\n\n// Create routes\nRoute.add(\"/\", () => \"Home Page\");\n\nRoute.group(\"/auth\", () => {\n\tRoute.add(\"/login\", () => \"Login Page\");\n\tRoute.add(\"/register\", () => \"Register Page\");\n});\n\n// Dynamic routes\nRoute.add(\"/users/{id}\", ({ params: { id } }) => {\n\treturn `User #${id}`;\n});\n\n// Start the router\nRouter.run();\n```\n\n---\n\n# 🌐 HTML Integration\n\nThe router automatically intercepts internal links and updates the page without refreshing the browser.\n\n```html\n<body>\n\t<nav>\n\t\t<a href=\"/\">Home</a>\n\t\t<a href=\"/auth/login\">Login</a>\n\t\t<a href=\"/auth/register\">Register</a>\n\t\t<a href=\"/users/10\">User Profile</a>\n\t</nav>\n\n\t<div id=\"root\"></div>\n\n\t<script src=\"app.js\"></script>\n</body>\n```\n\n---\n\n# 🏗 Router Workflow\n\n```txt\nUser Click\n     |\n     |\n Browser Event\n     |\n     |\n Router Engine\n     |\n     |\n Route Matching\n     |\n     |\n Middleware\n     |\n     |\n Component Rendering\n     |\n     |\n DOM Update\n```\n\n---\n\n# 📚 Routing Guide\n\n## Basic Routes\n\nCreate simple routes:\n\n```javascript\nRoute.add(\"/\", () => \"Welcome Page\");\n\nRoute.add(\"/about\", () => \"About Page\");\n```\n\n---\n\n## Route Groups\n\nOrganize related routes together.\n\n```javascript\nRoute.group(\"/auth\", () => {\n\tRoute.add(\"/login\", () => \"Login Page\");\n\tRoute.add(\"/register\", () => \"Register Page\");\n});\n```\n\nGenerated routes:\n\n```txt\n/auth/login\n/auth/register\n```\n\n---\n\n## Dynamic Routes\n\nCapture values directly from the URL.\n\n```javascript\nRoute.add(\"/users/{id}\", ({ params: { id } }) => {\n\treturn `User ID: ${id}`;\n});\n```\n\nMultiple parameters:\n\n```javascript\nRoute.add(\"/courses/{category}/{name}\", ({ params: { category, name } }) => {\n\treturn `${category} / ${name}`;\n});\n```\n---\n\n## Fallback Route ( 404 )\n\nCreate fallback route:\n\n```javascript\nRoute.fallback(() => \"404 | Not found\");\n\nRoute.fallback(() => \"404 | Not found\", \"SPA | 404\");\n```\n\n---\n\n# 🛡 Middleware\n\nMiddleware allows you to execute custom logic before rendering a route.\n\nCommon use cases:\n\n- Authentication checks\n- Logging\n- Analytics\n- Permissions\n- Data preparation\n\nExample:\n\n```javascript\nconst logger = () => {\n\tconsole.log(\"[LOG] Route visited\");\n};\n\nRoute.add(\"/dashboard\", () => \"Dashboard\").middleware([logger]);\n```\n\nGroup middleware:\n\n```javascript\nRoute.group(\"/admin\", () => {\n\tRoute.add(\"/users\", () => \"Users\");\n\tRoute.add(\"/settings\", () => \"Settings\");\n}).middleware([logger]);\n```\n\n---\n\n# 🔀 Route Redirection\n\nRedirect users to another route.\n\n```javascript\nRoute.add(\"/login\", () => \"Login Page\");\n\nRoute.add(\"/dashboard\", () => {\n\treturn Route.redirect(\"/login\");\n});\n```\n\n---\n\n# 🏷 Page Titles\n\nChange the browser tab title dynamically.\n\n```javascript\nRoute.add(\"/\", () => \"Home\").title(\"My Awesome SPA\");\n```\n\nIf no title is specified, the router uses the default `document.title`.\n\n---\n\n# 📂 Example Project Structure\n\n```txt\nexample/\n|\n├── assets/\n|         ├── lib/\n|                └── router.min.js\n|         └── scripts/\n|                    ├── pages.js\n|                    └── app.js\n|\n├── .gitignore\n├── index.html\n├── package.json\n└── server.js\n```\n\n### How to run this?\n```bash\ncd Router/examples/\nnpm install\nnpm start\n```\n\nAfter that, It’s available and you can follow it in your browser:\n```txt\nhttp://localhost:8000\n```\n\n---\n\n# 💡 Use Cases\n\nRouter can be used for:\n\n- Single Page Applications (SPA)\n- Dashboard interfaces\n- Admin panels\n- Personal websites\n- Progressive Web Applications\n- Educational projects to learn routing concepts\n\n---\n\n# 🔥 Why Router?\n\nTraditional websites require a full page reload for every navigation.\n\nWith Router:\n\n```txt\nTraditional Website\n\nClick Link\n    |\nHTTP Request\n    |\nServer Response\n    |\nReload Entire Page\n\n\nSPA Router\n\nClick Link\n    |\nJavaScript Router\n    |\nChange Route\n    |\nUpdate DOM\n```\n\nThis results in a faster and smoother user experience.\n\n---\n\n# 🧠 Concepts You Will Learn\n\nBy studying this project, you can understand:\n\n- Browser History API\n- URL parsing\n- Route matching algorithms\n- Dynamic parameters\n- Middleware patterns\n- Event handling\n- Client-side rendering\n- SPA architecture\n\n---\n\n# 👨‍💻 Author\n\n**Aref Shojaei**\n\n- 📧 Email: [arefshojaei82@gmail.com](mailto:arefshojaei82@gmail.com)\n- 🐙 GitHub: [@ArefShojaei](https://github.com/ArefShojaei)\n\n---\n\n# ⭐ Show Your Support\n\nIf this project helps you understand SPA architecture and client-side routing, consider giving it a **Star ⭐ on GitHub**.\n\nYour support helps the project grow.\n","readmeFilename":"README.md"}