Add client-side hash-based routing to a single-page app without jQuery or a full framework
Handle HTTP request routing in a Node.js server using the same API as your front-end router
Route command-line arguments in a Node.js CLI tool using the same library as the web app
Build URL-driven browser apps where content changes without full page reloads
Director is a small JavaScript library that handles URL routing. Routing is the part of a web application that decides which code runs when someone visits a particular address or clicks a particular link. Instead of writing that logic yourself, you define a table that maps URL patterns to functions, and Director calls the right function automatically. What makes Director unusual is that the same library works in two different environments: inside a browser and inside a Node.js server. Most routing tools are built for one or the other. Director supports both with the same API, which simplifies projects where you want consistent behavior on the front end and back end. It has no dependencies, so you do not need jQuery, Express, or any other framework to use it. In the browser, Director watches the part of the URL that comes after a hash symbol, such as the fragment in an address like example.com/#/books. When that fragment changes, usually because the user clicked a link, Director runs the function you associated with that route. This pattern is common in single-page applications, where the page never fully reloads but the content changes based on the URL. On a server running Node.js, Director routes incoming HTTP requests by URL and method, such as GET or POST, to the appropriate handler functions. It also supports a third mode for command-line tools, where routes are matched against arguments passed to a script rather than a URL. The library supports features like parameterized routes (where part of the URL is captured as a variable), wildcard patterns, asynchronous route handlers, and nested route tables. The README includes extensive code examples for each feature. Director is a fairly mature project from the Flatiron organization and appears to have been widely used, though the codebase has not seen recent activity.
← flatiron on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.