Skip to content

A simple pushstate router for React, with support for async routing logic. Bring your preferred parser, printer and state management.

Notifications You must be signed in to change notification settings

jonasbuntinx/purescript-wire-react-router

 
 

Repository files navigation

purescript-wire-react-router

A basic pushstate router for React with support for asynchronous routing logic, built using react-basic-hooks. I recommend routing-duplex for easy parsing and printing and wire for easy reactive state.

makeRouter ::
  forall route f.
  Foldable f =>
  PushStateInterface ->
  { parse :: String -> f route
  , print :: route -> String
  , onRoute :: route -> Router route Transitioning Resolved Unit
  , onTransition :: Transition route -> Effect Unit
  } ->
  Effect
    { component :: JSX
    , navigate :: route -> Effect Unit
    , redirect :: route -> Effect Unit
    }

For a basic example see examples/RoutingDuplex.purs.

How to use with Spago

Add wire-react-router to your packages.dhall:

let additions =
  { wire-react-router =
      { dependencies =
          [ "aff"
          , "freet"
          , "indexed-monad"
          , "profunctor-lenses"
          , "react-basic-hooks"
          , "routing"
          ]
      , repo = "https://github.com/robertdp/purescript-wire-react-router.git"
      , version = "v0.2.1"
      }
  }

And then install with $ spago install wire-react-router

About

A simple pushstate router for React, with support for async routing logic. Bring your preferred parser, printer and state management.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PureScript 63.3%
  • Dhall 36.7%