🚨 Disclaimer: Routify 3 is currently in Release Candidate stage.
Please be aware that while the documentation is comprehensive, it may contain inaccuracies or errors. The codebase is also subject to changes that could affect functionality. We appreciate your understanding and welcome any feedback or contributions.
api
Classes
Router
Router Options
Instance
(default: Root Instance
) The instance that this router belongs to.
RNode
(default: None
) Manually specify the root node. By default the root node from the routes object will be used.
string
(default: Empty string
) The name of the router. All routers inside an instance must have unique names.
RouteTree
(default: none
) The generated routes to be imported into the router.
UrlRewrite
BaseReflector | AddressReflector | InternalReflector | LocalStorageReflector
(default: AddressReflector
) Keeps the internal path synchronized to the browser (AddressReflector) or the local storage (LocalStorageReflector). InternalReflector does not synchronize the internal path to anything.
callback
callback
callback
Runs before the route has been changed.
callback
Runs after the route has been changed.
(RouteFragment[]) => RouteFragment[]
Manipulate the fragments returned by route.fragments
(Router) => void
Called when the router is destroyed
Router Options
Plugins share the same options as the router options.
QueryHandler
Synchronizes the query parameters with the path in the address bar.
ClickHandler
Configures which clicks the router listens to.
never | always | preserve | contextual
(default: never
) Whether or not to add a trailing slash to the URL. preserve
will keep the trailing slash if it was there, and contextual
will add a trailing slash if the URL is a directory, e.g.: /example/index.svelte.
UrlRewrite
(url, ctx) => string
Rewrites the external URL (visible in the address bar) before it's passed to the router.
(url, ctx) => string
Rewrites the internal URL before it's passed to the router (visible in the address bar).
QueryHandler
(search:string, route:Route) => Object
Parses the query string from the path and returns an object with parameters.
(params:Object, route:Route) => string
Serializes the parameters and returns a string.
ClickHandler
HTMLElement | () => HTMLElement
(default: parent element of router
) The element that will be listened to for clicks.
(event, url) => string | null
Can rewrite the url or ignore the click by returning null.