Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cloudflare/util-route-handler

Package Overview
Dependencies
Maintainers
19
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cloudflare/util-route-handler

Cloudflare Route Handler Util

  • 1.2.15
  • latest
  • npm
  • Socket score

Version published
Maintainers
19
Created
Source

cf-util-route-handler

Cloudflare Route Handler Util

Installation

$ npm install cf-util-route-handler

Usage

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:

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.

FAQs

Package last updated on 28 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc