universal-router
Advanced tools
Changelog
[3.0.0] - 2017-03-25
Update Router API (BREAKING CHANGE)
import Router from 'universal-router'
const router = new Router(routes, options)
router.resolve({ path, ...context }) // => Promise<any>
// previously
import { resolve } from 'universal-router'
resolve(routes, { path, ...context }) // => Promise<any>
See #83 for more info and examples
context.next()
now iterates only child routes by default (BREAKING CHANGE)<br>
use context.next(true)
to iterate through the all remaining routes
Remove babel-runtime
dependency to decrease library size (BREAKING CHANGE)<br>
Now you need to care about these polyfills yourself:
Add support for URL Generation
import generateUrls from 'universal-router/generate-urls'
const url = generateUrls(router)
url(routeName, params) // => String
Add support for Dynamic Breadcrumbs, use context.route.parent
to iterate
Add support for Declarative Routes, new Router(routes, { resolveRoute: customResolveRouteFn })
Add support for Base URL option, new Router(routes, { baseUrl: '/base' })
Add ability to specify custom context properties once, new Router(routes, { context: { ... } })
Rewrite matchRoute
function without usage of
generators
to decrease amount of necessary polyfills
Remove usage of String.prototype.startsWith()
Add context.url
with the original url passed to resolve
method
Add context
property to Route not found
error
Changelog
[2.0.0] - 2016-10-20
context.params
values from the parent route (#57)context.end()
method (#60)match
alias for resolve
function (#59)null
the same way as undefined
(#51)null
instead of undefined
to signal no match (#51)context.next()
across multiple routes (#49)Changelog
[1.2.1] - 2016-05-12
match()
to resolve()
. E.g. import { resovle } from 'universal-router'
children
propertyChangelog
[1.1.0-beta.3] - 2016-04-08
matchRoute()
yielding the same route twice when it matches to both full and base URLsChangelog
[1.1.0-beta.2] - 2016-04-08
match(routes, { path, ...context)
now throws an error if a matching route was not found (BREAKING CHANGE)/error
, it will be used for error handling by conventionChangelog
[1.1.0-beta.1] - 2016-04-05
Router
class and router.dispatch()
method in favor of
match(routes, { path, ...context })
, where routes
is just a plain JavaScript objects containing
the list of routes (BREAKING CHANGE)context.end()
method to be used from inside route actionsChangelog
[1.0.0-beta.1] - 2016-03-25
react-routing
to universal-router
(BREAKING CHANGE)router.on(path, ...actions)
in favor of router.route(path, ...actions)
(BREAKING CHANGE)new Router(on => { ... })
initialization option in favor of new Router(routes)
(BREAKING CHANGE)docs/assets
.package.json
, update Babel and its plug-ins to the latest versionsbabel-runtime
package instead of an inline runtime