0.5.2 • Published 4 years ago

nuro-router v0.5.2

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

Nuro Router

WORK IN PROGRESS

A simple SPA router for Nuro apps.

Features

  • Navigate between pages without a browser refresh
  • Utilizes the browser history API so back/forward buttons still work
  • URL parameters

Install

npm install nuro-router

or

<script src="path/to/nuro-router.js"></script>

Usage

First install NuroRouter as a plugin. Then you can use the router's components in your components

import { Nuro } from 'nuro'
import { NuroRouter } from 'nuro-router'

Nuro.install(NuroRouter)

class FooComponent {
  template = `<div>Foo</div>`
}

class BarComponent {
  template = `<div>Bar {{props.routeParams.id}}</div>`
}

class HomeComponent {
  template = `<div>Home</div>`
}

class PageNotFoundComponent {
  template = `<div>Page not found</div>`
}

class AppRouter {
  template = `
    <div>
      <nav>
        <ul>
          <li>
            <router-link to="/">Home</router-link>
          </li>
          <li>
            <router-link to="/foo">Foo</router-link>
          </li>
          <li>
            <router-link to="/bar/123">Bar 123</router-link>
          </li>
        </ul>
      </nav>
      <router-switch :routes="routes"></router-switch>
    </div>
  `
  beforeInit() {
    this.routes = [
      { path: "/foo", component: FooComponent },
      { path: "/bar/:id", component: BarComponent },
      { path: "/", component: HomeComponent },
      { path: "*", component: PageNotFoundComponent}
    ]
  }
}

Nuro.mount(AppRouter)
0.5.2

4 years ago

0.5.0

4 years ago

0.5.1

4 years ago

0.4.5

4 years ago

0.4.4

4 years ago

0.4.7

4 years ago

0.4.6

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago