This repository has been archived by the owner on Apr 29, 2023. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hyperapp#2 Support (Updating)
Implemented with state-first in mind, simplicity and consistency to hav#1 router.
This Router follows simple concept of state-driven components (as hyperapp itself), the only one possible way to route component is to properly update application state (location). Router doesn't tightly depend on window.history anymore, that means you can use multiple applications at once.
Router internally uses 'path-to-regexp' syntax to compile paths this brings more routing power and consistency with other frameworks.
Quick start
Since routing depends on state, 'state.location' should be defined at first.
Each 'Route' component should receive 'location' property to process routes.
Link component is used to properly update 'state.location'.
more details at Route Params
Usage Examples
Base example
Using Route 'render' property and nested 'Route' component
||
Route Parameters
Using nested 'Route' component for nested routes, route context (to pass properties to nested components and routes), using route params
Redirects
Redirect as subscription
No Match (Default)
History
If you want to expose
state.location
and subscribe to window.history,use 'history' as subscription
Router#v2 API
location
location.back
location.go
history
Link
Route
Redirect