npm.io
0.2.7 • Published 8 years ago

hyperapp-hoa-router

Licence
ISC
Version
0.2.7
Deps
1
Size
41 kB
Vulns
0
Weekly
0
Stars
1

A Hyperapp Router

Demo

Quick Start

import { app } from 'hyperapp'
import { createHashHistory } from 'history'
import { withRouter, routerFactory } from 'hyperapp-hoa-router'
import App from './components/App'

const history = createHashHistory()

const config = {
  factories: [routerFactory(history)]
}

withRouter(app, config)({}, {}, App, document.body)

or

import { app } from 'hyperapp'
import { createHashHistory } from 'history'
import { init, routerFactory } from 'hyperapp-hoa-router'
import App from './App'

init('router')
const router = routerFactory(createHashHistory())
const main = app(
  { router: router.state },
  { router: router.actions },
  App,
  document.body
)
router.sub(main)

Components

Components are basically identify with hyperapp/router components

  • Route

  • Switch

  • Link

  • Redirect

Dependencies Reference

Hyperapp: 1 kB JavaScript framework for building web applications.

History: Easily manage session history anywhere JavaScript runs. Abstracts away the differences in various environments and provides a minimal API that lets you manage the history stack, navigate, confirm navigation, and persist state between sessions.

Keywords