Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including router5 with all npm packages installed. Try it out:

var router5 = require("router5")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

router5 v8.0.1

A simple, powerful, view-agnostic, modular and extensible router


npm version License: MIT Build Status Join the chat at styled with prettier

Official website:

router5 is a framework and view library agnostic router.

  • view / state separation: router5 processes routing instructions and outputs state updates.
  • universal: works client-side and server-side
  • simple: define your routes, start to listen to route changes
  • flexible: you have control over transitions and what happens on transitions
import createRouter from 'router5'
import browserPlugin from 'router5-plugin-browser'

const routes = [
  { name: 'home', path: '/' },
  { name: 'profile', path: '/profile' }

const router = createRouter(routes)



With React (hooks)

import React from 'react'
import ReactDOM from 'react-dom'
import { RouterProvider, useRoute } from 'react-router5'

function App() {
  const { route } = useRoute()

  if (!route) {
    return null

  if ( === 'home') {
    return <h1>Home</h1>

  if ( === 'profile') {
    return <h1>Profile</h1>

  <RouterProvider router={router}>
    <App />

With observables

Your router instance is compatible with most observable libraries.

import { from } from 'rxjs/observable/from'

from(router).map(({ route }) => {
  /* happy routing */




RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free