Hop: Navigation and routing helpers for Elm SPAs
Hop is a helper library meant to be used with:
- Navigation v1 for listening to location changes in the browser and pushing changes to it.
- UrlParser v1 for constructing routes and parsing URLs.
As of version 6 Hop doesn't include matchers anymore, instead I have decided to favour the UrlParser library which provides a more flexible way of building matchers.
What Hop provides
On top of these two packages above, Hop helps with:
- Abstracting the differences between push or hash routing
- Providing helpers for working with the query string
- Encode / Decode the location path
- Encode / Decode the query string
Please see this example app. It explains how to wire everything in the comments.
A proper url should have the query before the hash e.g.
but when using hash routing, query parameters are appended after the hash path e.g.
This is done for aesthetics and so the router is fully controlled by the hash fragment.
examples/full folders. To run the example apps:
- Clone this repo
- Go to example folder
- Follow the readme in that folder