/hop

Navigation and routing helpers for single page applications in Elm

Primary LanguageElmMIT LicenseMIT

Hop: Navigation and routing helpers for Elm SPAs

Build Status

alt Hop

Hop is a helper library meant to be used with:

  • Navigation for listening to location changes in the browser and pushing changes to it.
  • UrlParser 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

Getting Started

Please see this example app. It explains how to wire everything in the comments.

Docs

Building routes

Nesting routes

Matching routes

Navigating

Reverse routing

API

Changelog

Testing Hop

More docs

Upgrade guide 5 to 6

Upgrade guide 4 to 5

Upgrade guide 3 to 4

Upgrade guide 2.1 to 3.0

Version 5 documentation

Version 4 documentation

Version 3 documentation

Version 2 documentation

Hash routing

A proper url should have the query before the hash e.g. ?keyword=Ja#/users/1, but when using hash routing, query parameters are appended after the hash path e.g. #/users/1?keyword=Ja. This is done for aesthetics and so the router is fully controlled by the hash fragment.

Examples

See examples/basic and examples/full folders. To run the example apps:

  • Clone this repo
  • Go to example folder
  • Follow the readme in that folder