@contextjs/routing
Version:
Declarative, fast, and extensible route matching for ContextJS applications.
47 lines (32 loc) • 1.58 kB
Markdown
# @contextjs/routing
[](https://github.com/contextjs/context/actions/workflows/tests.yaml)
[](https://www.npmjs.com/package/@contextjs/routing)
[](https://github.com/contextjs/context/blob/main/LICENSE)
> Declarative, extensible route matching and configuration for ContextJS-based applications.
## Features
- Fully type-safe and fluent route configuration
- Support for literal, parameterized, optional, and catch-all route templates
- Fast route matching with scoring and early-exit optimization
- URI decoding, normalization, and edge-case tolerance
- Integration with the `Application` class via `useRouting()`
## Installation
```bash
npm i @contextjs/routing
```
## Usage
```ts
import { Application } from "@contextjs/system";
import { RouteInfo } from "@contextjs/routing";
const app = new Application();
app.useRouting();
```
## Matching Example
```ts
import { RouteService } from "@contextjs/routing";
const route = RouteService.match("home/123/details", [...routeDefinitions]);
console.log(route?.template); // "home/{id?}/details"
```
## API Reference
For detailed API documentation, please refer to the [API Reference](https://contextjs.dev/api/routing#api-reference).
## Testing
All features are covered by 100% unit test coverage, ensuring reliability, correctness, and long-term maintainability - so you can focus on building, not debugging.