mthadley / elm-hash-routing / Browser.Hash

Check out the README for more a more in depth explanation of why this package exists. Otherwise, skip down application to get started.

application : { init : flags -> Url -> Browser.Navigation.Key -> ( model, Platform.Cmd.Cmd msg ), view : model -> Browser.Document msg, update : msg -> model -> ( model, Platform.Cmd.Cmd msg ), subscriptions : model -> Platform.Sub.Sub msg, onUrlRequest : Browser.UrlRequest -> msg, onUrlChange : Url -> msg } -> Platform.Program flags model msg

A replacement for Browser.application that will automatically process your hash-based Url's into ones that will work out of the box with the standard parsing logic of Url.Parser.

It's usage is the same as Browser.application:

import Browser.Hash as Hash

main : Program () Model Msg
main =
    Hash.application
        { init = init
        , view = view
        , update = update
        , subscriptions = subscriptions
        , onUrlChange = App.RouteChange << Router.parse
        , onUrlRequest = App.OnUrlRequest
        }