All Projects → ChrisRu → es6-router

ChrisRu / es6-router

Licence: MIT license
🌐 Simple client side router built in ES6

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to es6-router

Redux Tower
Saga powered routing engine for Redux app.
Stars: ✭ 155 (+868.75%)
Mutual labels:  router, routing
Routerify
A lightweight, idiomatic, composable and modular router implementation with middleware support for the Rust HTTP library hyper.rs
Stars: ✭ 173 (+981.25%)
Mutual labels:  router, routing
Router
⚡️ A lightning fast HTTP router
Stars: ✭ 158 (+887.5%)
Mutual labels:  router, routing
Router5
Flexible and powerful universal routing solution
Stars: ✭ 1,704 (+10550%)
Mutual labels:  router, routing
Klein.php
A fast & flexible router
Stars: ✭ 2,622 (+16287.5%)
Mutual labels:  router, routing
Grip
The microframework for writing powerful web applications.
Stars: ✭ 137 (+756.25%)
Mutual labels:  router, routing
Flow builder
Flutter Flows made easy! A Flutter package which simplifies flows with a flexible, declarative API.
Stars: ✭ 169 (+956.25%)
Mutual labels:  router, routing
React Page Layout
Create layouts for react
Stars: ✭ 117 (+631.25%)
Mutual labels:  router, routing
Falco
A functional-first toolkit for building brilliant ASP.NET Core applications using F#.
Stars: ✭ 214 (+1237.5%)
Mutual labels:  router, routing
Ui Router
The de-facto solution to flexible routing with nested views in AngularJS
Stars: ✭ 13,738 (+85762.5%)
Mutual labels:  router, routing
Bsdrp
BSD Router Project
Stars: ✭ 126 (+687.5%)
Mutual labels:  router, routing
Swiftuirouter
Routing in SwiftUI
Stars: ✭ 242 (+1412.5%)
Mutual labels:  router, routing
Django Macros Url
Django Macros URL. Routing must be simple as possible
Stars: ✭ 121 (+656.25%)
Mutual labels:  router, routing
Nextjs Dynamic Routes
[Deprecated] Super simple way to create dynamic routes with Next.js
Stars: ✭ 145 (+806.25%)
Mutual labels:  router, routing
Universal Router
A simple middleware-style router for isomorphic JavaScript web apps
Stars: ✭ 1,598 (+9887.5%)
Mutual labels:  router, routing
Rayo.js
Micro framework for Node.js
Stars: ✭ 170 (+962.5%)
Mutual labels:  router, routing
Phprouter
PhpRouter is a powerful, minimal, and very fast HTTP URL router for PHP projects
Stars: ✭ 97 (+506.25%)
Mutual labels:  router, routing
Php Router
simple and flexible Router class for PHP. with Controllers and Middlewares support.
Stars: ✭ 111 (+593.75%)
Mutual labels:  router, routing
Next Routes
Universal dynamic routes for Next.js
Stars: ✭ 2,354 (+14612.5%)
Mutual labels:  router, routing
Router
Router implementation for fasthttp
Stars: ✭ 234 (+1362.5%)
Mutual labels:  router, routing

ES6 Router

Licence Tests

A simple client side router built in ES6 with 0 dependencies and TypeScript definitions.

Usage

const router = new Router({ ... })
  .add(() => {
    // getPage('/');
  })
  .add(/about/, () => {
    // getPage('about');
  })
  .add('contact', () => {
    // getPage('contact');
  });

router.remove('contact');
router.navigate('about');

API

constuctor

Param Type Description
options Object Options object
options.debug boolean (false) Enable debugging
options.context Object (window) Context to add event listener to
options.startListening boolean (true) Start listening when router is created

currentRoute ⇒ string

Name of the current route

Returns: string - Current route


add(route, handler) ⇒ Router

Add a new route

Param Type Description
re string | RegExp Name of route to match
handler function Method to execute when route matches

Returns: Router - This router instance


remove(route, [handler]) ⇒ Router

Remove a route from the routerc

Param Type Description
re string | RegExp Name of route to remove
[handler] function Function handler to remove

Returns: Router - This router instance


reload() ⇒ Router

Reload the current route

Returns: Router - This router instance


listen([instance]) ⇒ Router

Start listening for hash changes on the window

Param Type Default Description
[instance] any Window Context to start listening on

Returns: Router - This router instance


stopListen([instance]) ⇒ Router

Stop listening for hash changes on the window

Param Type Default Description
[instance] any Window Context to stop listening on

Returns: Router - This router instance


navigate(path) ⇒ Router

Navigate router to path

Param Type Description
path string Path to navigate the router to

Returns: Router - This router instance


navigateError(hash) ⇒ Router

Navigate to the error page

Param Type
hash string

Returns: Router - This router instance


cleanPath(path) ⇒ string

Strip the path of slashes and hashes

Param Type Description
path string Path to clean of hashes

Returns: string - Cleaned path


parseRoute(path) ⇒ string

Parse a route URL to get all parts

Param Type Description
path string Route to split into parts

Returns: string[] - Parts of the url

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].