# @bleckert/router

> Simple router

Latest version **0.2.0** (published 2022-06-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install @bleckert/router
pnpm add @bleckert/router
yarn add @bleckert/router
bun add @bleckert/router
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2022-06-14 |
| First published | 2022-06-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 0 |
| Unpacked size | 6.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Author | Tobias Bleckert |
| Maintainers | tbleckert |
| Keywords | router, js, simple, callback, init, small |

## Links

- npm: https://www.npmjs.com/package/@bleckert/router
- Repository: https://github.com/tbleckert/location-init
- Issues: https://github.com/tbleckert/location-init/issues
- npm.io page: https://npm.io/package/@bleckert/router

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.2.0 (latest) — 2022-06-14

## README

Router
=============
_<0.5kb minified and gzipped_

## Install

Download dist/module.js or install with npm (`npm install @bleckert/router`).

## Usage

Simply create a new router like this:

    const router = new Router();

You can also create the router with a base url (will be prepended on all routes) and/or a routes object.

    const router = new Router('/user', {
    	profile(route, path) {

    	},
    	settings(route, path) {

    	}
    });

You can also add routes after init and call `dispatch` manually. This is how you add routes:

    router.on('/profile', (route, path, event) => {

    });

    router.on('/splat/*', (route, path, event) => {

    });

    router.on('/named/:id', (route, path, event) => {

    });

    router.dispatch();

---
_Source: https://npm.io/package/@bleckert/router · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
