# cf-util-route-handler

> Cloudflare Route Handler Util

Latest version **4.2.5** (published 2018-03-28) · BSD-3-Clause license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install cf-util-route-handler
pnpm add cf-util-route-handler
yarn add cf-util-route-handler
bun add cf-util-route-handler
```

## Health

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

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 4.2.5 |
| Published | 2018-03-28 |
| First published | 2015-12-31 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | James Kyle |
| Maintainers | adamschwartz, cf-ci, cf-ci-write, ereeves, hamidagh, handrews, hturan, inikulin, jculvey, johndotawesome, jparyani-cloudflare, manatarms, marksteyn, miksu, mpint, nkcmr, rreverser, ryan0x44, sejoker, teffenellis, terinjokes, toekneestuck, vasturiano |

## Links

- npm: https://www.npmjs.com/package/cf-util-route-handler
- npm.io page: https://npm.io/package/cf-util-route-handler

## Recent versions

- 4.2.5 (latest) — 2018-03-28
- 2.0.2 (stable) — 2016-02-05
- 4.2.4 — 2018-03-27
- 4.2.3 — 2017-10-23
- 4.2.2 — 2017-10-20
- 4.2.1 — 2017-09-22
- 4.2.0 — 2017-03-20
- 4.1.0 — 2017-03-20
- 4.0.1 — 2017-02-27
- 4.0.0 — 2016-12-01
- 3.0.0 — 2016-05-16
- 2.0.3 — 2016-03-11
- 2.0.1 — 2016-02-05
- 2.0.0 — 2016-02-02
- 1.0.0 — 2015-12-31

## README

# cf-util-route-handler

> Cloudflare Route Handler Util

## Installation

```sh
$ npm install cf-util-route-handler
```

## Usage

```js
import {handleRoutes, routeTo} from 'cf-util-route-handler';
import Backbone from 'backbone';

// setup the router
handleRoutes(function(url) {
  Backbone.history.navigate(url, true);
});

// do all the world to make the router work normally
new Backbone.Router({
  routes: {
    ''    : () => console.log('/'),
    hello : () => console.log('/hello'),
    world : () => console.log('/world')
  }
});
Backbone.history.start();

// start routing
routeTo('/');
routeTo('/hello');
routeTo('/world');
```

A handler looks like this:

```js
handleRoutes(url => {
  takeActionWithUrl(url);
});
```

Only one handler is allowed to be setup.

`routeTo` is fire and forget, there's no callback for async transitions, and
it does not return anything.

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