{"library":"radix3","title":"Radix3 Router","description":"Radix3 is a lightweight and high-performance routing library for JavaScript and TypeScript, currently stable at version 1.1.2. It implements a Radix Tree data structure to offer efficient route matching, making it particularly well-suited for server-side applications, API gateways, and edge runtimes where request routing speed is critical. The library maintains an active development cadence, with regular minor releases introducing enhancements and performance improvements, as seen in the recent updates to v0.8.x and v1.x. Its key differentiators include its minimal footprint, speed, and robust support for various route patterns like named parameters, wildcards, and regex-like segments. It also provides utilities for exporting and rehydrating route matchers, enabling pre-compiled routing logic for faster startup times. Radix3 ships with full TypeScript type definitions, ensuring a strong developer experience.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install radix3"],"cli":null},"imports":["import { createRouter } from 'radix3';","import { createRouter, toRouteMatcher } from 'radix3';","import { exportMatcher, createMatcherFromExport } from 'radix3';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { createRouter, toRouteMatcher, exportMatcher, createMatcherFromExport } from 'radix3';\n\n// 1. Create a router instance and add routes\nconst router = createRouter({\n  strictTrailingSlash: false,\n  routes: {\n    '/': { name: 'home' },\n    '/users': { name: 'users-list' },\n    '/users/:id': { name: 'user-detail' },\n    '/assets/**': { name: 'static-assets' },\n    '/docs/:version/**': { name: 'docs-wildcard' }\n  }\n});\n\n// 2. Lookup routes\nconsole.log('Matching /users:', router.lookup('/users'));\n// Expected: { name: 'users-list' }\n\nconsole.log('Matching /users/123:', router.lookup('/users/123'));\n// Expected: { name: 'user-detail', params: { id: '123' } }\n\nconsole.log('Matching /assets/img/logo.png:', router.lookup('/assets/img/logo.png'));\n// Expected: { name: 'static-assets' }\n\n// 3. Create a multi-matcher to find all matching routes\nconst matcher = toRouteMatcher(router);\nconst allMatches = matcher.matchAll('/docs/v1/introduction');\nconsole.log('All matches for /docs/v1/introduction:', allMatches.map(m => m.name));\n// Expected: ['docs-wildcard']\n\n// 4. Export and rehydrate matcher for persistence/pre-compilation\nconst exportedMatcher = exportMatcher(matcher);\n// In a real scenario, `exportedMatcher` would be serialized (e.g., to JSON) and loaded later.\nconst rehydratedMatcher = createMatcherFromExport(exportedMatcher);\nconsole.log('Rehydrated matcher matching /users:', rehydratedMatcher.matchAll('/users').map(m => m.name));\n// Expected: ['users-list']\n","lang":"typescript","description":"Demonstrates creating a Radix3 router, inserting various route patterns (static, named, wildcard), performing lookups, and utilizing the `toRouteMatcher` and `exportMatcher` utilities for advanced matching and persistence.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}