Nifty Pony Merchandise

    vanilla-spa-router

    1.7.0 • Public • Published

    vanilla-spa-router

    Simple-to-use VanillaJS (SPA) Router

    Probably you even no need to use this but it's ok :)

    Advantages:

    • NO dependencies
    • NO conflicts
    • NO overrides
    • just include as source or module
    • IE6+, Firefox 2+

    Installation

    ... as source <script src="router.js"></script> ... as module yarn add vanilla-spa-router

    API

    Use window._Router(ops) or new Router(ops) to access to routing

    Available options

    • mode: 'history'(default) or 'hash' Choose the way of routing
    • base: '/'(default) Set base directory

    Methods

    • .init(ops) Rebind your options accordingly
    • .start() Start working with router using History API or #anchor
    • .use(String route, Function middleware) Subscribe for router updates for exact path with needed params middleware(Object data) - Receives transformed data from path name. You can continue working straight with Router using this inside middleware
    • .navigate(String path) Replaces you to the needed location

    Install

    npm i vanilla-spa-router

    DownloadsWeekly Downloads

    2

    Version

    1.7.0

    License

    GNU

    Unpacked Size

    44.7 kB

    Total Files

    6

    Last publish

    Collaborators

    • rshtg