{"id":10751,"library":"director","title":"Director Router","description":"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.","status":"abandoned","version":"1.2.8","language":"javascript","source_language":"en","source_url":"http://github.com/flatiron/director","tags":["javascript","URL","router","http","cli","flatiron","client side","ender"],"install":[{"cmd":"npm install director","lang":"bash","label":"npm"},{"cmd":"yarn add director","lang":"bash","label":"yarn"},{"cmd":"pnpm add director","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"For Node.js environments, Director is primarily used via CommonJS `require()`. It does not officially support ESM, and direct ESM imports will likely fail without a transpilation step.","wrong":"import Router from 'director';","symbol":"Router","correct":"const Router = require('director');"},{"note":"When included via a script tag in the browser, Director exposes the `Router` constructor as a global variable. This can lead to naming collisions with other libraries.","symbol":"Router (browser global)","correct":"<script src=\"path/to/director.min.js\"></script>\n<script> var router = Router(routes); </script>"}],"quickstart":{"code":"<!DOCTYPE html>\n<html>\n  <head>\n    <meta charset=\"utf-8\">\n    <title>Director Client-Side Routing Example</title>\n    <script src=\"https://rawgit.com/flatiron/director/master/build/director.min.js\"></script>\n    <script>\n      var author = function () { console.log(\"Route: author\"); };\n      var books = function () { console.log(\"Route: books\"); };\n      var viewBook = function (bookId) {\n        console.log(\"Route: viewBook, ID: \" + bookId);\n      };\n\n      var routes = {\n        '/author': author,\n        '/books': [books, function() {\n          console.log(\"Route: An inline handler for books.\");\n        }],\n        '/books/view/:bookId': viewBook\n      };\n\n      var router = Router(routes);\n      router.init();\n\n      console.log('Router initialized. Click links to test hash-based routing.');\n    </script>\n  </head>\n  <body>\n    <h1>Director Client-Side Router</h1>\n    <ul>\n      <li><a href=\"#/author\">#/author</a></li>\n      <li><a href=\"#/books\">#/books</a></li>\n      <li><a href=\"#/books/view/123\">#/books/view/123</a></li>\n      <li><a href=\"#/books/view/456\">#/books/view/456</a></li>\n    </ul>\n    <p>Check the console for route handler output.</p>\n  </body>\n</html>","lang":"javascript","description":"Demonstrates basic client-side hash-based routing in an HTML file using Director, logging route events to the console."},"warnings":[{"fix":"Migrate to a actively maintained routing library like `react-router`, `vue-router`, or `express` (for server-side).","message":"The `director` package is abandoned and has not been updated in nearly a decade. Its dependencies are outdated, and it lacks modern features like official ESM support or the HTML5 History API. It is not recommended for new projects.","severity":"deprecated","affected_versions":">=1.2.8"},{"fix":"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).","message":"The provided quickstart examples use `rawgit.com` for CDN delivery, which has been deprecated since 2019. Directly linking to GitHub raw files for production is also a security risk and unreliable.","severity":"deprecated","affected_versions":"*"},{"fix":"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.","message":"Director primarily relies on hash-based routing (`#/path`) for client-side applications. It does not natively support the HTML5 History API (`pushState`, `replaceState`), which is the standard for modern single-page applications.","severity":"gotcha","affected_versions":"*"},{"fix":"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).","message":"In browser environments, Director exposes the `Router` constructor as a global variable. This can lead to naming collisions if other scripts on the page also define a global `Router`.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'1.2.8':71 'across':38 'adopt':97 'ago':76 'aim':32 'api':102 'applic':26 'base':45,54,83 'browser':16,87 'cadenc':110 'cli':24,140 'client':14,47,105,142 'client-sid':13,46,104 'command':61 'command-lin':60 'current':67 'decad':75 'depend':30 'dependency-fre':29 'differ':35 'director':1,5 'due':126 'effect':112 'ender':144 'environ':39 'featur':41,134 'flatiron':141 'focus':79 'free':31 'hash':44,82 'hash-bas':43,81 'histori':101 'html5':100 'http':22,139 'includ':42 'interfac':63 'javascript':25,136 'key':40 'lack':129 'librari':4 'line':62 'mainten':131 'make':120 'mani':118 'match':92 'minim':34 'modern':133 'near':73 'new':124 'node.js':21,57 'packag':65 'path':53,91 'path-bas':52 'predat':95 'primarili':78 'project':125 'provid':7 'releas':72,109 'rout':9,49,55,84,107 'router':2,6,138 'server':19,58,94 'server-sid':18 'side':15,20,48,106,143 'solut':10 'stabl':68 'stall':113 'support':135 'tradit':51,89 'unsuit':122 'updat':116 'url':90,137 'usag':37 'version':69 'widespread':96 'year':119","created_at":"2026-04-19T13:34:26.174902+00:00","updated_at":"2026-04-19T13:34:26.174902+00:00","problems":[{"fix":"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.","cause":"The Director library script (`director.min.js`) was not loaded correctly in the browser, or `Router` is being accessed before it's available.","error":"ReferenceError: Router is not defined"},{"fix":"Use `const Router = require('director');` for CommonJS imports in Node.js. Avoid destructuring if `Router` is the default export, or attempting ESM `import` statements.","cause":"In a Node.js environment, the `director` package was imported incorrectly, or `require('director')` did not return the `Router` constructor as expected.","error":"TypeError: Router is not a function"},{"fix":"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()`).","cause":"The requested URL path does not match any of the routes defined in the router's configuration.","error":"Error: Route '/my/missing/path' not found"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.2.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/flatiron/director","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/director","openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}