# @goldpage/path-to-regexp

Latest version **0.5.13** (published 2020-11-12) · 0 weekly downloads

## Install

```sh
npm install @goldpage/path-to-regexp
pnpm add @goldpage/path-to-regexp
yarn add @goldpage/path-to-regexp
bun add @goldpage/path-to-regexp
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.13 |
| Published | 2020-11-12 |
| First published | 2019-09-08 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 14.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 57 |
| Maintainers | brillout |

## Links

- npm: https://www.npmjs.com/package/@goldpage/path-to-regexp
- Repository: https://github.com/reframejs/goldpage
- Homepage: https://github.com/reframejs/goldpage#readme
- Issues: https://github.com/reframejs/goldpage/issues
- npm.io page: https://npm.io/package/@goldpage/path-to-regexp

## Dependencies (3)

- [@brillout/reassert](https://npm.io/package/@brillout/reassert.md) ^0.1.1
- [@brillout/reconfig](https://npm.io/package/@brillout/reconfig.md) 0.5.13
- [@brillout/path-to-regexp](https://npm.io/package/@brillout/path-to-regexp.md) ^0.1.2

## Recent versions

- 0.5.13 (latest) — 2020-11-12
- 0.5.12 — 2020-11-12
- 0.5.11 — 2020-10-13
- 0.5.10 — 2020-10-01
- 0.5.9 — 2020-09-27
- 0.5.8 — 2020-09-17
- 0.5.7 — 2020-07-22
- 0.5.6 — 2020-03-22
- 0.5.5 — 2019-10-14
- 0.5.4 — 2019-10-03
- 0.5.3 — 2019-10-02
- 0.5.2 — 2019-09-14
- 0.5.1 — 2019-09-09
- 0.5.0 — 2019-09-08

## README

<!---






    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/path-to-regexp/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/path-to-regexp/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/path-to-regexp/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/path-to-regexp/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/path-to-regexp/readme.template.md` and run `npm run docs` (or `yarn docs`).






-->

Goldpage + `path-to-regexp` = :heart:

# `@goldpage/path-to-regexp`

Routing with [`path-to-regexp`](https://github.com/pillarjs/path-to-regexp).

(Note that `@goldpage/path-to-regexp` doesn't use the npm module `path-to-regexp` directly, but uses a modified version [`@brillout/path-to-regexp`](https://github.com/brillout/path-to-regexp).)

### Usage

Install `@goldpage/path-to-regexp`.

~~~bash
$ npm install @goldpage/path-to-regexp
~~~

The plugin is automatically loaded and
the `route` property of your page configs is now handled by `path-to-regexp`.

### Example

~~~js
// /examples/basics/pages/hello.page.js

import React, {useState} from 'react';

export default {
  route: '/hello/:name',
  addInitialProps,
  view: Hello,
  title,
  renderToHtml: true,
};

async function addInitialProps({name}) {
  // We simulate a network request delay
  await sleep(0.5);

  const nameReversed = name.split('').reverse().join('');
  return {nameReversed};
}

function Hello({name, nameReversed}) {
  const [isReversed, setReverse] = useState(false);

  return (
    <div>
      Hello <span>{isReversed ? nameReversed : name}</span>, welcome to Goldpage.
      <br/>
      <button onClick={() => setReverse(!isReversed)}>Reverse name</button>
    </div>
  );
}

function title({name}) {
  return 'Hi '+name;
}

function sleep(seconds) {
  let resolve;
  const promise = new Promise(r => resolve=r);
  setTimeout(resolve, seconds*1000);
  return promise;
}
~~~

<!---






    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/path-to-regexp/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/path-to-regexp/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/path-to-regexp/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/path-to-regexp/readme.template.md` and run `npm run docs` (or `yarn docs`).












    WARNING, READ THIS.
    This is a computed file. Do not edit.
    Instead, edit `/plugins/path-to-regexp/readme.template.md` and run `npm run docs` (or `yarn docs`).






-->

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