This library, Director Router, provides a routing solution for both client-side (browser) and server-side (Node.js HTTP and CLI) JavaScript applications. It is dependency-free, aiming for minimal differences in usage across environments. Key features include hash-based client-side routing, and traditional path-based routing for Node.js servers and command-line interfaces. The package's current stable version is 1.2.8, released nearly a decade ago. It primarily focuses on hash-based routing for the browser and traditional URL path matching for servers, predating widespread adoption of the HTML5 History API for client-side routing. Its release cadence is effectively stalled, with no updates in many years, making it unsuitable for new projects due to a lack of maintenance and modern feature support.
npm install directorVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic client-side hash-based routing in an HTML file using Director, logging route events to the console.
Migrate to a actively maintained routing library like `react-router`, `vue-router`, or `express` (for server-side).
Do not use `rawgit.com` or direct GitHub raw links. For testing, download the script locally or use a proper CDN if one were available (which is not the case for Director).
If History API support is crucial, you will need to implement a custom solution or choose a different routing library. Director's core design is centered on hash-routing.
Ensure `director.min.js` is loaded after any potential conflicting libraries, or rename the global `Router` if possible (which Director does not explicitly support out-of-the-box, making it a design limitation).
Ensure the `<script>` tag for `director.min.js` is present and correctly linked in your HTML, and that your application code accessing `Router` runs after the library has loaded.
Use `const Router = require('director');` for CommonJS imports in Node.js. Avoid destructuring if `Router` is the default export, or attempting ESM `import` statements.Verify that the URL path being accessed exactly matches a defined route pattern, including any parameters. Ensure the router is initialized and listening for changes (e.g., `router.init()`).
No dependency data recorded yet.