**This repo is under heavy development and everything from code to documentation is far from complete.
If you have questions about how to use Routify 3, please see the docs or visit us on Discord.
Create a new Routify project with
npx @roxi/routify@next create myapp
Basic
<script>
import { Router } from '@roxi/routify'
import routes from '../.routify/routes.default.js'
</script>
<Router {routes} />Create instance manually
<script>
import { Routify, Router } from '@roxi/routify'
import routes from '../.routify/routes.default.js'
const instance = new Routify({ routes, /* options */ })
</script>
<Router {instance} />// create a root node
const rootNode = instance.superNode.createChild('my-root-node')
// create a page node
rootNode.createChild('im-page-1', module)
rootNode.createChild('im-page-2', module)
// Note: module can be a module or its path// create a root node
const rootNode = instance.createNode('my-root-node')
instance.superNode.appendChild(rootNode)
// create a page node
const childNode = instance.createNode('my-child-node')
rootNode.appendChild(childNode)- Global (class)
- Instance (class)
- nodeIndex (array)
- superNode (class)
- Router* (module)
- Router (class)
- params
- activeUrl** (ActiveUrl)
- activeRoute** (Route)
- fragments (RouteFragment[])
- module* (module)
- module* (module)
- module* (module) ...
- module* (module)
- Router (class)
- Instance (class)
**: Store
- RoutifyBuildtimePayload
- RoutifyCallback
- RoutifyBuildtimeOptions
- RoutifyRuntimeOptions
- TransformFragmentsCallback
- RoutifyExternalMetaHelper
- RoutifyLoadReturn
- RoutifyBuildtimeRuntimePlugin
- RoutifyRuntimePlugin
- RoutifyBasePlugin
- RoutifyBuildtimePluginType
- MetaContextSplit
- MetaContext
- UrlRewriteFn
- UrlRewrite
- QueryHandler
- QueryHandlerParse
- QueryHandlerStringify
- ComponentGuardFn
- PathNode
- UrlState
- FragmentContext
- NodeTreeExport
- BrowserAdapter
COMMON
Type: {instance: RoutifyBuildtime, tools: any}
Type: Function
first{instance: Routify}
Returns (T | Promise<T>)
Type: Object
-
NodeRNodeBuildtime -
routifyDirstring defaults to '.routify' -
clearRoutifyDirboolean -
filemapperobject -
routesDir(string | Object<string, string>) defaults to { default: 'src/routes' } -
extensionsArray<(string | RegExp)> defaults to ['.svelte', '.html', '.md', '.svx'], -
watchboolean rebuild Routify routes on changes
Type: Object
instanceRoutifyRuntime instance to use. Uses global by defaultrootNodeRNodeRuntimeroutesany the routes treenamestring name of router - leave blank if only only one router is usedurlRewrite(UrlRewrite | Array<UrlRewrite>) hook: transforms paths to and from router and browserurlstring? initial url - "/" by defaultpassthrough(Boolean | Router) ignore clicksbeforeRouterInitMaybeArray<RouterInitCallback> hook: runs before each router initiationafterRouterInitMaybeArray<RouterInitCallback> hook: runs after each router initiationbeforeUrlChangeMaybeArray<BeforeUrlChangeCallback> hook: guard that runs before url changesafterUrlChangeMaybeArray<AfterUrlChangeCallback> hook: runs after url has changedtransformFragmentsMaybeArray<TransformFragmentsCallback> hook: transform route fragments after navigationonDestroyMaybeArray<OnDestroyRouterCallback> hook: runs before router is destroyedqueryHandlerQueryHandlerpluginsArray<Partial<RoutifyRuntimeOptions>>
Type: function (Array<RouteFragment>): Array<RouteFragment>
Type: Object
instanceRoutifyRuntimeoptionsany //todotempPathstring
Type: object
contextRoutifyLoadContext
routeRoutenodeRNodeRuntimestatusnumbererror(string | Error)redirectstringmaxagenumberpropsobject
Returns MaybePromise<(Partial<RoutifyLoadReturn> | null)>
Type: object
pathstring example: '@roxi/routify/plugins/reset'importeestring the imported name from the path, defaults to "default"optionsobject options passed to the runtime plugin
Type: Partial<RoutifyRuntimeOptions>
Type: Object
namestring? name of pluginbefore(string | Array<string>)? name of plugin(s) to run beforeafter(string | Array<string>)? name of plugin(s) to run afteroptionsfunction (Partial<RoutifyBuildtimeOptions>): Partial<RoutifyBuildtimeOptions> runs before "build"
Type: Object
buildfunction (RoutifyBuildtimePayload): (Promise<any> | any)? runs after "options"pathstring?metaRoutifyExternalMetaHelper?runtimePluginsArray<RoutifyBuildtimeRuntimePlugin>
Type: Function
valueany the value to be splitnamestring? defaults to hashed value
Modify the context available to meta files
Type: Object
instanceRoutifyBuildtimenodeRNodeBuildtimeoptionsPartial<RoutifyBuildtimeOptions>splitMetaContextSplit? dynamically import the valuetempPathstring temporary path for the respective file, eg. ./.routify/cached/src/routes/index.svelte/
Type: Function
urlstringctx{router: Router}
Returns string
Type: Object
toInternalUrlRewriteFntoExternalUrlRewriteFn
Type: Object
parseQueryHandlerParsestringifyQueryHandlerStringify
Type: Function
searchstringrouteRoute
Returns Object<string, string>
Type: Function
Returns string
Type: Function
routeRoute
guardComponentGuardFn?loadRoutifyLoad?
Type: Object
urlFragmentstringnodeRNodeRuntime
Type: ("pushState" | "replaceState" | "popState")
Type: Object
routeRoutenodeRNodeRuntimeloadfunction? preload functionality for pages and moduleslocalParamsObject<string, any>
Type: Object
idstringnamestring?moduleanyrootNamestring?fileany?childrenArray<NodeTreeExport>
Type: Object