Skip to content

gulewei/router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Hyperapp Router

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.