# delir

> Generates a Route Manifest for you. It allows you to refer to a page by name instead of location

Latest version **0.1.0** (published 2022-04-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install delir
pnpm add delir
yarn add delir
bun add delir
```

Provides the command `delir`.

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2022-04-15 |
| First published | 2021-10-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 18.6 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Victor Bury |
| Maintainers | anymaniax |
| Keywords | code-generation, react, next |

## Links

- npm: https://www.npmjs.com/package/delir
- Repository: https://github.com/anymaniax/delir
- Homepage: https://github.com/anymaniax/delir#readme
- Issues: https://github.com/anymaniax/delir/issues
- npm.io page: https://npm.io/package/delir

## Dependencies (5)

- [cac](https://npm.io/package/cac.md) ^6.7.8
- [chalk](https://npm.io/package/chalk.md) ^4.1.2
- [upath](https://npm.io/package/upath.md) ^2.0.1
- [fs-extra](https://npm.io/package/fs-extra.md) ^10.0.0
- [path-to-regexp](https://npm.io/package/path-to-regexp.md) 6.2.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2022-04-15
- 0.0.1 — 2021-10-11

## README

`Delir` generates a _Route Manifest_ for you. It allows you to refer to a
page by _name_ instead of _location_:

## Install

```bash
  npm install -g delir
```

## How to use

```bash
  delir ./your-output-file
```

```bash
  delir ./your-output-file --workspace ./your-next-app-folder
```

## Example

```tsx
// Assume you have a page at app/pages/products/[productId].tsx
export default function ProductsPage() { ...

// You can then use Routes...
import { Link } from "next"
import { Routes } from "../path-to-manifest-file"

// ...to refer to it by name...
<Link href={Routes.ProductsPage({ productId: 123 })} />

// ...instead of looking up the location!
<Link href={`/products/${123}`} />
```

The _Route Manifest_ has some advantages:

- improved expressiveness
- simplifies moving pages to new locations

## Query Parameters {#query-parameters}

Query parameters can be specified together with route parameters.

```tsx
// instead of ...
<Link href={`/products/${pid}?offerCode=capybara`} />

// ... you can do:
<Link href={Routes.Product({ pid, offerCode: "capybara" })} />
```

Simple cli which is an extract of the [routes manifest](https://blitzjs.com/docs/route-manifest) feature from [blitz](https://blitzjs.com/). Thanks for the super framework ❤️


## Route matching

```tsx
// Assume you have a page at app/pages/products/[productId].tsx
export default function ProductsPage() { ... }

import { useRouter } from 'next/router';
// You can then use Routes...
import { Routes } from "../path-to-manifest-file";

// in your server api
Routes.ProductsPage.isActive(someobject.path)

// generically without next router
Routes.ProductsPage.isActive(window.location.pathname)

// with asPath from useRouter
const { asPath } = useRouter();
Routes.ProductsPage.isActive(asPath);
```

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