diff --git a/docs/api/classes/NavigationAbandonedError.md b/docs/api/classes/NavigationAbandonedError.md
new file mode 100644
index 00000000..b67987b8
--- /dev/null
+++ b/docs/api/classes/NavigationAbandonedError.md
@@ -0,0 +1,60 @@
+# Classes: NavigationAbandonedError
+
+Thrown when data a getter is waiting on is discarded because navigation moved elsewhere.
+
+## Extends
+
+- `Error`
+
+## Constructors
+
+### Constructor
+
+```ts
+new NavigationAbandonedError(): NavigationAbandonedError;
+```
+
+#### Returns
+
+`NavigationAbandonedError`
+
+#### Overrides
+
+```ts
+Error.constructor
+```
+
+## Methods
+
+### isError()
+
+```ts
+static isError(error): error is Error;
+```
+
+Indicates whether the argument provided is a built-in Error instance or not.
+
+#### Parameters
+
+| Parameter | Type |
+| ------ | ------ |
+| `error` | `unknown` |
+
+#### Returns
+
+`error is Error`
+
+#### Inherited from
+
+```ts
+Error.isError
+```
+
+## Properties
+
+| Property | Type | Inherited from |
+| ------ | ------ | ------ |
+| `cause?` | `unknown` | `Error.cause` |
+| `message` | `string` | `Error.message` |
+| `name` | `string` | `Error.name` |
+| `stack?` | `string` | `Error.stack` |
diff --git a/docs/api/components/RouterLink.md b/docs/api/components/RouterLink.md
index 4787cadb..2da5a96a 100644
--- a/docs/api/components/RouterLink.md
+++ b/docs/api/components/RouterLink.md
@@ -8,6 +8,8 @@ A component to render a link to a route or any url.
## Param
+**props**
+
The props to pass to the router link component.
## Returns
diff --git a/docs/api/components/RouterView.md b/docs/api/components/RouterView.md
index 9e474b88..68a8cad7 100644
--- a/docs/api/components/RouterView.md
+++ b/docs/api/components/RouterView.md
@@ -8,6 +8,8 @@ A component to render the current route's component.
## Param
+**props**
+
The props to pass to the router view component.
## Returns
diff --git a/docs/api/compositions/useLink.md b/docs/api/compositions/useLink.md
index 0b142916..573b87ab 100644
--- a/docs/api/compositions/useLink.md
+++ b/docs/api/compositions/useLink.md
@@ -10,14 +10,20 @@ for navigating.
## Param
+**source**
+
The name of the route or a valid URL.
## Param
+**params**
+
If providing route name, this argument will expect corresponding params.
## Param
+**options**
+
[RouterResolveOptions](../types/RouterResolveOptions.md) Same options as router resolve.
## Returns
diff --git a/docs/api/compositions/useRoute.md b/docs/api/compositions/useRoute.md
index f29e6baf..b0b6c2d0 100644
--- a/docs/api/compositions/useRoute.md
+++ b/docs/api/compositions/useRoute.md
@@ -14,10 +14,14 @@ if provided, throwing an error if the validation fails at any point during the c
## Template
+**TRouteName**
+
A string type that should match route name of the registered router, ensuring the route name exists.
## Param
+**routeName**
+
Optional. The name of the route to validate against the current active routes.
## Returns
diff --git a/docs/api/errors/LoaderDataAccessError.md b/docs/api/errors/LoaderDataAccessError.md
new file mode 100644
index 00000000..507af91e
--- /dev/null
+++ b/docs/api/errors/LoaderDataAccessError.md
@@ -0,0 +1,67 @@
+# Errors: LoaderDataAccessError
+
+An error thrown when a loader reads the data of the route it belongs to. That data includes what the
+loader itself is computing, so reading it could only wait on the loader that is doing the reading.
+
+## Extends
+
+- `Error`
+
+## Constructors
+
+### Constructor
+
+```ts
+new LoaderDataAccessError(name?): LoaderDataAccessError;
+```
+
+#### Parameters
+
+| Parameter | Type |
+| ------ | ------ |
+| `name?` | `string` |
+
+#### Returns
+
+`LoaderDataAccessError`
+
+#### Overrides
+
+```ts
+Error.constructor
+```
+
+## Methods
+
+### isError()
+
+```ts
+static isError(error): error is Error;
+```
+
+Indicates whether the argument provided is a built-in Error instance or not.
+
+#### Parameters
+
+| Parameter | Type |
+| ------ | ------ |
+| `error` | `unknown` |
+
+#### Returns
+
+`error is Error`
+
+#### Inherited from
+
+```ts
+Error.isError
+```
+
+## Properties
+
+| Property | Type | Inherited from |
+| ------ | ------ | ------ |
+| `cause?` | `unknown` | `Error.cause` |
+| `message` | `string` | `Error.message` |
+| `name` | `string` | `Error.name` |
+| `stack?` | `string` | `Error.stack` |
diff --git a/docs/api/errors/LoaderNameConflict.md b/docs/api/errors/LoaderNameConflict.md
new file mode 100644
index 00000000..0fbf9188
--- /dev/null
+++ b/docs/api/errors/LoaderNameConflict.md
@@ -0,0 +1,68 @@
+# Errors: LoaderNameConflict
+
+An error thrown when a loader is added with the same name as a loader on one of the route's ancestors.
+A route's data combines the loaders of every match, so the same name twice would be ambiguous rather
+than an override.
+
+## Extends
+
+- `Error`
+
+## Constructors
+
+### Constructor
+
+```ts
+new LoaderNameConflict(name?): LoaderNameConflict;
+```
+
+#### Parameters
+
+| Parameter | Type |
+| ------ | ------ |
+| `name?` | `string` |
+
+#### Returns
+
+`LoaderNameConflict`
+
+#### Overrides
+
+```ts
+Error.constructor
+```
+
+## Methods
+
+### isError()
+
+```ts
+static isError(error): error is Error;
+```
+
+Indicates whether the argument provided is a built-in Error instance or not.
+
+#### Parameters
+
+| Parameter | Type |
+| ------ | ------ |
+| `error` | `unknown` |
+
+#### Returns
+
+`error is Error`
+
+#### Inherited from
+
+```ts
+Error.isError
+```
+
+## Properties
+
+| Property | Type | Inherited from |
+| ------ | ------ | ------ |
+| `cause?` | `unknown` | `Error.cause` |
+| `message` | `string` | `Error.message` |
+| `name` | `string` | `Error.name` |
+| `stack?` | `string` | `Error.stack` |
diff --git a/docs/api/functions/createRoute.md b/docs/api/functions/createRoute.md
index e51461a8..52791485 100644
--- a/docs/api/functions/createRoute.md
+++ b/docs/api/functions/createRoute.md
@@ -1,7 +1,7 @@
# Functions: createRoute()
```ts
-function createRoute(options, ...args): ToRoute & InternalRouteHooks, ExtractRouteContext> & RouteRedirects> & RouteSetTitle>;
+function createRoute(options, ...args): RouteWithMethods, ToRouteMatches>;
```
## Type Parameters
@@ -20,4 +20,4 @@ function createRoute(options, ...args): ToRoute & `InternalRouteHooks`\<[`ToRoute`](../types/ToRoute.md)\<`TOptions`\>, `ExtractRouteContext`\<`TOptions`\>\> & [`RouteRedirects`](../types/RouteRedirects.md)\<[`ToRoute`](../types/ToRoute.md)\<`TOptions`\>\> & `RouteSetTitle`\<[`ToRoute`](../types/ToRoute.md)\<`TOptions`\>\>
+`RouteWithMethods`\<`ToRouteUrl`\<`TOptions`\>, `ToRouteMatches`\<`TOptions`, `TProps`\>\>
diff --git a/docs/api/hooks/onAfterRouteLeave.md b/docs/api/hooks/onAfterRouteLeave.md
index e3959de2..2dc09c76 100644
--- a/docs/api/hooks/onAfterRouteLeave.md
+++ b/docs/api/hooks/onAfterRouteLeave.md
@@ -9,6 +9,8 @@ This can be used for cleanup actions after the component is no longer active, en
## Param
+**AfterRouteHook**
+
The hook callback function
## Returns
diff --git a/docs/api/hooks/onAfterRouteUpdate.md b/docs/api/hooks/onAfterRouteUpdate.md
index 9287f670..e263698d 100644
--- a/docs/api/hooks/onAfterRouteUpdate.md
+++ b/docs/api/hooks/onAfterRouteUpdate.md
@@ -9,6 +9,8 @@ This is ideal for responding to updates within the same route, such as parameter
## Param
+**AfterRouteHook**
+
The hook callback function
## Returns
diff --git a/docs/api/hooks/onBeforeRouteLeave.md b/docs/api/hooks/onBeforeRouteLeave.md
index 4a293b5f..4e8b6f05 100644
--- a/docs/api/hooks/onBeforeRouteLeave.md
+++ b/docs/api/hooks/onBeforeRouteLeave.md
@@ -9,6 +9,8 @@ This is useful for performing actions or cleanups before navigating away from a
## Param
+**BeforeRouteHook**
+
The hook callback function
## Returns
diff --git a/docs/api/hooks/onBeforeRouteUpdate.md b/docs/api/hooks/onBeforeRouteUpdate.md
index 0efc9f45..f1f03539 100644
--- a/docs/api/hooks/onBeforeRouteUpdate.md
+++ b/docs/api/hooks/onBeforeRouteUpdate.md
@@ -9,6 +9,8 @@ This is particularly useful for handling changes in route parameters or query wh
## Param
+**BeforeRouteHook**
+
The hook callback function
## Returns
diff --git a/docs/api/index.md b/docs/api/index.md
index e018314a..48de746e 100644
--- a/docs/api/index.md
+++ b/docs/api/index.md
@@ -11,6 +11,8 @@
## Errors
- [DuplicateParamsError](errors/DuplicateParamsError.md)
+- [LoaderDataAccessError](errors/LoaderDataAccessError.md)
+- [LoaderNameConflict](errors/LoaderNameConflict.md)
- [MetaPropertyConflict](errors/MetaPropertyConflict.md)
- [RouterNotInstalledError](errors/RouterNotInstalledError.md)
- [UseRouteInvalidError](errors/UseRouteInvalidError.md)
@@ -24,6 +26,10 @@
- [isRoute](type-guards/isRoute.md)
- [isUrlString](type-guards/isUrlString.md)
+## Classes
+
+- [NavigationAbandonedError](classes/NavigationAbandonedError.md)
+
## Components
- [RouterLink](components/RouterLink.md)
@@ -63,7 +69,11 @@
- [AddBeforeLeaveHook](types/AddBeforeLeaveHook.md)
- [AddBeforeUpdateHook](types/AddBeforeUpdateHook.md)
- [AddErrorHook](types/AddErrorHook.md)
+- [AddLoaderOptions](types/AddLoaderOptions.md)
- [AddRejectionHook](types/AddRejectionHook.md)
+- [AddViewOptions](types/AddViewOptions.md)
+- [AddViewPropsCallbackContext](types/AddViewPropsCallbackContext.md)
+- [AddViewPropsGetter](types/AddViewPropsGetter.md)
- [AfterEnterHook](types/AfterEnterHook.md)
- [AfterEnterHookContext](types/AfterEnterHookContext.md)
- [AfterHookLifecycle](types/AfterHookLifecycle.md)
@@ -88,6 +98,7 @@
- [HookLifecycle](types/HookLifecycle.md)
- [HookRemove](types/HookRemove.md)
- [LiteralParam](types/LiteralParam.md)
+- [LoaderGetter](types/LoaderGetter.md)
- [Param](types/Param.md)
- [ParamExtras](types/ParamExtras.md)
- [ParamGetSet](types/ParamGetSet.md)
@@ -112,6 +123,11 @@
- [ResolvedRoute](types/ResolvedRoute.md)
- [ResolvedRouteUnion](types/ResolvedRouteUnion.md)
- [Route](types/Route.md)
+- [RouteAddLoader](types/RouteAddLoader.md)
+- [RouteAddView](types/RouteAddView.md)
+- [RouteCallbackContext](types/RouteCallbackContext.md)
+- [RouteLoader](types/RouteLoader.md)
+- [RouteLoaders](types/RouteLoaders.md)
- [RouteMeta](types/RouteMeta.md)
- [Router](types/Router.md)
- [RouterAssets](types/RouterAssets.md)
@@ -133,12 +149,14 @@
- [RouterRoutes](types/RouterRoutes.md)
- [RouterRouteUnion](types/RouterRouteUnion.md)
- [RouterViewPropsGetter](types/RouterViewPropsGetter.md)
+- [RouteViews](types/RouteViews.md)
- [ToCallback](types/ToCallback.md)
- [ToRoute](types/ToRoute.md)
- [Url](types/Url.md)
- [UrlString](types/UrlString.md)
- [UseLink](types/UseLink.md)
- [UseLinkOptions](types/UseLinkOptions.md)
+- [WithData](types/WithData.md)
- [WithHost](types/WithHost.md)
- [WithoutHost](types/WithoutHost.md)
- [WithoutParent](types/WithoutParent.md)
diff --git a/docs/api/type-guards/isRoute.md b/docs/api/type-guards/isRoute.md
index 5059eacf..85272bc8 100644
--- a/docs/api/type-guards/isRoute.md
+++ b/docs/api/type-guards/isRoute.md
@@ -8,6 +8,8 @@ A guard to verify if a route or unknown value matches a given route name.
## Param
+**routeName**
+
The name of the route to check against the current route.
## Returns
diff --git a/docs/api/typedoc-sidebar.json b/docs/api/typedoc-sidebar.json
index be161dfa..5c09ac69 100644
--- a/docs/api/typedoc-sidebar.json
+++ b/docs/api/typedoc-sidebar.json
@@ -33,6 +33,14 @@
"text": "DuplicateParamsError",
"link": "/api/errors/DuplicateParamsError.md"
},
+ {
+ "text": "LoaderDataAccessError",
+ "link": "/api/errors/LoaderDataAccessError.md"
+ },
+ {
+ "text": "LoaderNameConflict",
+ "link": "/api/errors/LoaderNameConflict.md"
+ },
{
"text": "MetaPropertyConflict",
"link": "/api/errors/MetaPropertyConflict.md"
@@ -71,6 +79,16 @@
}
]
},
+ {
+ "text": "Classes",
+ "collapsed": true,
+ "items": [
+ {
+ "text": "NavigationAbandonedError",
+ "link": "/api/classes/NavigationAbandonedError.md"
+ }
+ ]
+ },
{
"text": "Components",
"collapsed": true,
@@ -205,10 +223,26 @@
"text": "AddErrorHook",
"link": "/api/types/AddErrorHook.md"
},
+ {
+ "text": "AddLoaderOptions",
+ "link": "/api/types/AddLoaderOptions.md"
+ },
{
"text": "AddRejectionHook",
"link": "/api/types/AddRejectionHook.md"
},
+ {
+ "text": "AddViewOptions",
+ "link": "/api/types/AddViewOptions.md"
+ },
+ {
+ "text": "AddViewPropsCallbackContext",
+ "link": "/api/types/AddViewPropsCallbackContext.md"
+ },
+ {
+ "text": "AddViewPropsGetter",
+ "link": "/api/types/AddViewPropsGetter.md"
+ },
{
"text": "AfterEnterHook",
"link": "/api/types/AfterEnterHook.md"
@@ -305,6 +339,10 @@
"text": "LiteralParam",
"link": "/api/types/LiteralParam.md"
},
+ {
+ "text": "LoaderGetter",
+ "link": "/api/types/LoaderGetter.md"
+ },
{
"text": "Param",
"link": "/api/types/Param.md"
@@ -401,6 +439,26 @@
"text": "Route",
"link": "/api/types/Route.md"
},
+ {
+ "text": "RouteAddLoader",
+ "link": "/api/types/RouteAddLoader.md"
+ },
+ {
+ "text": "RouteAddView",
+ "link": "/api/types/RouteAddView.md"
+ },
+ {
+ "text": "RouteCallbackContext",
+ "link": "/api/types/RouteCallbackContext.md"
+ },
+ {
+ "text": "RouteLoader",
+ "link": "/api/types/RouteLoader.md"
+ },
+ {
+ "text": "RouteLoaders",
+ "link": "/api/types/RouteLoaders.md"
+ },
{
"text": "RouteMeta",
"link": "/api/types/RouteMeta.md"
@@ -485,6 +543,10 @@
"text": "RouterViewPropsGetter",
"link": "/api/types/RouterViewPropsGetter.md"
},
+ {
+ "text": "RouteViews",
+ "link": "/api/types/RouteViews.md"
+ },
{
"text": "ToCallback",
"link": "/api/types/ToCallback.md"
@@ -509,6 +571,10 @@
"text": "UseLinkOptions",
"link": "/api/types/UseLinkOptions.md"
},
+ {
+ "text": "WithData",
+ "link": "/api/types/WithData.md"
+ },
{
"text": "WithHost",
"link": "/api/types/WithHost.md"
diff --git a/docs/api/types/AddLoaderOptions.md b/docs/api/types/AddLoaderOptions.md
new file mode 100644
index 00000000..0218cf71
--- /dev/null
+++ b/docs/api/types/AddLoaderOptions.md
@@ -0,0 +1,20 @@
+# Types: AddLoaderOptions\
+
+```ts
+type AddLoaderOptions = object;
+```
+
+The options for a loader added via `addLoader`.
+
+## Type Parameters
+
+| Type Parameter | Default type | Description |
+| ------ | ------ | ------ |
+| `TName` *extends* `string` \| `undefined` | `string` | The loader's name, inferred from the `name` option. |
+
+## Properties
+
+| Property | Type | Description |
+| ------ | ------ | ------ |
+| `name?` | `TName` | The name of the loader, which is the key its data is exposed under on the route. Defaults to the unnamed loader, whose data is exposed as the route's data directly. |
+| `prefetch?` | [`PrefetchConfig`](PrefetchConfig.md) | Determines whether this loader is run when a router-link is rendered for this route. Overrides route level prefetch, and is itself overridden by link level prefetch. |
diff --git a/docs/api/types/AddViewOptions.md b/docs/api/types/AddViewOptions.md
new file mode 100644
index 00000000..4a25666a
--- /dev/null
+++ b/docs/api/types/AddViewOptions.md
@@ -0,0 +1,22 @@
+# Types: AddViewOptions\
+
+```ts
+type AddViewOptions = object;
+```
+
+The options for a view added via `addView`.
+
+## Type Parameters
+
+| Type Parameter | Default type | Description |
+| ------ | ------ | ------ |
+| `TName` *extends* `string` \| `undefined` | `string` | The view's name, inferred from the `name` option. |
+| `TGetter` | [`PropsGetter`](PropsGetter.md) | The view's props getter, inferred from the `props` option. |
+
+## Properties
+
+| Property | Type | Description |
+| ------ | ------ | ------ |
+| `name?` | `TName` | The name of the view, rendered by ``. Defaults to the unnamed view. |
+| `prefetch?` | [`PrefetchConfig`](PrefetchConfig.md) | Determines what assets are prefetched for this view when a router-link is rendered for this route. Overrides route level prefetch, and is itself overridden by link level prefetch. |
+| `props?` | `TGetter` | A props getter for the view. Receives the resolved route and a context object. |
diff --git a/docs/api/types/AddViewPropsCallbackContext.md b/docs/api/types/AddViewPropsCallbackContext.md
new file mode 100644
index 00000000..eb070cb9
--- /dev/null
+++ b/docs/api/types/AddViewPropsCallbackContext.md
@@ -0,0 +1,14 @@
+# Types: AddViewPropsCallbackContext\
+
+```ts
+type AddViewPropsCallbackContext = RouteCallbackContext;
+```
+
+Context provided to an `addView` props getter. The same context a loader is given, since both are
+callbacks attached to a route.
+
+## Type Parameters
+
+| Type Parameter |
+| ------ |
+| `TRoute` *extends* [`Route`](Route.md) |
diff --git a/docs/api/types/AddViewPropsGetter.md b/docs/api/types/AddViewPropsGetter.md
new file mode 100644
index 00000000..1ba8631d
--- /dev/null
+++ b/docs/api/types/AddViewPropsGetter.md
@@ -0,0 +1,26 @@
+# Types: AddViewPropsGetter\
+
+```ts
+type AddViewPropsGetter = (route, context) => MaybePromise>;
+```
+
+The props getter for a view added via `addView`. Receives the same two arguments as the
+`createRoute` props callback: the resolved route and a context object.
+
+## Type Parameters
+
+| Type Parameter |
+| ------ |
+| `TRoute` *extends* [`Route`](Route.md) |
+| `TComponent` *extends* `Component` |
+
+## Parameters
+
+| Parameter | Type |
+| ------ | ------ |
+| `route` | [`ResolvedRoute`](ResolvedRoute.md)\<`TRoute`\> & [`WithData`](WithData.md)\<`TRoute`\> |
+| `context` | [`AddViewPropsCallbackContext`](AddViewPropsCallbackContext.md)\<`TRoute`\> |
+
+## Returns
+
+`MaybePromise`\<`ComponentProps`\<`TComponent`\>\>
diff --git a/docs/api/types/CreateRouteOptions.md b/docs/api/types/CreateRouteOptions.md
index 852b8388..6f38ce8c 100644
--- a/docs/api/types/CreateRouteOptions.md
+++ b/docs/api/types/CreateRouteOptions.md
@@ -15,8 +15,8 @@ type CreateRouteOptions = object;
| Property | Type | Description |
| ------ | ------ | ------ |
-| `component?` | `Component` | An optional component to render when this route is matched. **Default** `RouterView` |
-| `components?` | `Record`\<`string`, `Component`\> | An object of named components to render using named views |
+| ~~`component?`~~ | `Component` | An optional component to render when this route is matched. **Default** `RouterView` **Deprecated** Use the chainable `addView` method on the route instead: `createRoute({ ... }).addView(component, { props })`. |
+| ~~`components?`~~ | `Record`\<`string`, `Component`\> | An object of named components to render using named views **Deprecated** Use the chainable `addView` method on the route instead: `createRoute({ ... }).addView(component, { name, props })`. |
| `context?` | `RouteContext`[] | Related routes and rejections for the route. The context is exposed to the hooks and props callback functions for this route. |
| `hash?` | `string` \| `UrlPart` | Hash part of URL. |
| `hoist?` | `boolean` | When true, the route will be hoisted to the top of the route tree. The route will continue to inherit meta, state, hooks, matches, and context from it's parent, but not the "url" properties. |
diff --git a/docs/api/types/CreatedRouteOptions.md b/docs/api/types/CreatedRouteOptions.md
index 5c1ffa88..36309b56 100644
--- a/docs/api/types/CreatedRouteOptions.md
+++ b/docs/api/types/CreatedRouteOptions.md
@@ -1,10 +1,12 @@
# Types: CreatedRouteOptions
```ts
-type CreatedRouteOptions = Omit & object;
+type CreatedRouteOptions = Omit & object;
```
-The Route properties originally provided to `createRoute`. The only change is normalizing meta to always default to an empty object.
+The Route properties originally provided to `createRoute`, plus the views that route renders and the
+loaders it runs. The deprecated `component`/`components` options are folded into `views` (see
+[RouteViews](RouteViews.md)).
## Type Declaration
@@ -14,8 +16,14 @@ The Route properties originally provided to `createRoute`. The only change is no
id: string;
```
-### props?
+### loaders
```ts
-optional props?: unknown;
+loaders: RouteLoaders;
+```
+
+### views
+
+```ts
+views: RouteViews;
```
diff --git a/docs/api/types/ErrorHookContext.md b/docs/api/types/ErrorHookContext.md
index 96ce51f7..349cc811 100644
--- a/docs/api/types/ErrorHookContext.md
+++ b/docs/api/types/ErrorHookContext.md
@@ -20,6 +20,6 @@ type ErrorHookContext = object;
| `push` | [`RouterPush`](RouterPush.md)\<`TRoutes`\> |
| `reject` | [`RouterReject`](RouterReject.md)\<`TRejections`\> |
| `replace` | [`RouterReplace`](RouterReplace.md)\<`TRoutes`\> |
-| `source` | `"props"` \| `"hook"` \| `"component"` |
+| `source` | `"props"` \| `"loader"` \| `"hook"` \| `"component"` |
| `to` | [`RouterResolvedRouteUnion`](RouterResolvedRouteUnion.md)\<`TRoutes`\> |
| `update` | `RouteUpdate`\<[`ResolvedRoute`](ResolvedRoute.md)\<`TRoute`\>\> |
diff --git a/docs/api/types/LoaderGetter.md b/docs/api/types/LoaderGetter.md
new file mode 100644
index 00000000..2e7f75ef
--- /dev/null
+++ b/docs/api/types/LoaderGetter.md
@@ -0,0 +1,28 @@
+# Types: LoaderGetter\
+
+```ts
+type LoaderGetter = (route, context) => unknown;
+```
+
+The getter for a loader added via `addLoader`. Receives the same two arguments as an `addView` props
+getter, except that its route carries no data: a route's data includes what the loader itself is
+computing, so reading it could only wait on itself. A parent's data is reached through the context.
+
+Unlike a props getter it can return anything, since nothing binds what it returns to a component.
+
+## Type Parameters
+
+| Type Parameter | Default type |
+| ------ | ------ |
+| `TRoute` *extends* [`Route`](Route.md) | [`Route`](Route.md) |
+
+## Parameters
+
+| Parameter | Type |
+| ------ | ------ |
+| `route` | [`ResolvedRoute`](ResolvedRoute.md)\<`TRoute`\> |
+| `context` | [`RouteCallbackContext`](RouteCallbackContext.md)\<`TRoute`\> |
+
+## Returns
+
+`unknown`
diff --git a/docs/api/types/PrefetchConfigs.md b/docs/api/types/PrefetchConfigs.md
index 0350b43a..b043698a 100644
--- a/docs/api/types/PrefetchConfigs.md
+++ b/docs/api/types/PrefetchConfigs.md
@@ -11,3 +11,4 @@ type PrefetchConfigs = object;
| `linkPrefetch?` | [`PrefetchConfig`](PrefetchConfig.md) |
| `routePrefetch?` | [`PrefetchConfig`](PrefetchConfig.md) |
| `routerPrefetch?` | [`PrefetchConfig`](PrefetchConfig.md) |
+| `viewPrefetch?` | [`PrefetchConfig`](PrefetchConfig.md) |
diff --git a/docs/api/types/PropsCallbackParent.md b/docs/api/types/PropsCallbackParent.md
index 341375c5..d93715a2 100644
--- a/docs/api/types/PropsCallbackParent.md
+++ b/docs/api/types/PropsCallbackParent.md
@@ -4,6 +4,7 @@
type PropsCallbackParent = Route | undefined extends TParent ?
| undefined
| {
+ data: unknown;
name: string;
props: unknown;
} : TParent extends Route ? object : undefined;
diff --git a/docs/api/types/PropsGetter.md b/docs/api/types/PropsGetter.md
index 3a90a887..c0d622bb 100644
--- a/docs/api/types/PropsGetter.md
+++ b/docs/api/types/PropsGetter.md
@@ -15,7 +15,7 @@ type PropsGetter = (route, context) => MaybePromise\> |
+| `route` | [`ResolvedRoute`](ResolvedRoute.md)\<[`ToRoute`](ToRoute.md)\<`TOptions`\>\> & [`WithData`](WithData.md)\<[`ToRoute`](ToRoute.md)\<`TOptions`\>\> |
| `context` | [`PropsCallbackContext`](PropsCallbackContext.md)\<[`ToRoute`](ToRoute.md)\<`TOptions`\>, `TOptions`\> |
## Returns
diff --git a/docs/api/types/ResolvedRoute.md b/docs/api/types/ResolvedRoute.md
index 43b7b79f..c62c7b3f 100644
--- a/docs/api/types/ResolvedRoute.md
+++ b/docs/api/types/ResolvedRoute.md
@@ -5,7 +5,7 @@ type ResolvedRoute = Readonly<{
hash: string;
href: UrlString;
id: TRoute["id"];
- matched: TRoute["matched"];
+ matched: MatchedRoute;
matches: TRoute["matches"];
name: TRoute["name"];
params: UrlParamsReading;
diff --git a/docs/api/types/Route.md b/docs/api/types/Route.md
index 2d93759e..62f8687d 100644
--- a/docs/api/types/Route.md
+++ b/docs/api/types/Route.md
@@ -1,7 +1,7 @@
-# Types: Route\
+# Types: Route\
```ts
-type Route = TUrl & object;
+type Route = TUrl & object;
```
Represents the structure of a route within the application. Return value of `createRoute`
@@ -11,7 +11,7 @@ Represents the structure of a route within the application. Return value of `cre
### context
```ts
-context: TContext;
+context: RouteContextOf;
```
Related routes and rejections for the route. The context is exposed to the hooks and props callback functions for this route.
@@ -24,14 +24,6 @@ id: string;
Unique identifier for the route, generated by router.
-### matched
-
-```ts
-matched: LastInArray;
-```
-
-The specific route properties that were matched in the current route.
-
### matches
```ts
@@ -44,7 +36,7 @@ Order of routes will be from greatest ancestor to narrowest matched.
### meta
```ts
-meta: TMeta;
+meta: RouteMetaOf;
```
Represents additional metadata associated with a route, combined with any parents.
@@ -52,7 +44,7 @@ Represents additional metadata associated with a route, combined with any parent
### name
```ts
-name: TName;
+name: RouteNameOf;
```
Identifier for the route as defined by user. Name must be unique among named routes. Name is used for routing and for matching.
@@ -68,7 +60,7 @@ Determines what assets are prefetched when router-link is rendered for this rout
### state
```ts
-state: TState;
+state: RouteStateOf;
```
Represents the schema of the route state, combined with any parents.
@@ -77,17 +69,5 @@ Represents the schema of the route state, combined with any parents.
| Type Parameter | Default type | Description |
| ------ | ------ | ------ |
-| `TName` *extends* `string` | `string` | Represents the unique name identifying the route, typically a string. |
-| `TUrl` *extends* [`Url`](Url.md) | [`Url`](Url.md) | - |
-| `TMeta` *extends* [`RouteMeta`](RouteMeta.md) | [`RouteMeta`](RouteMeta.md) | - |
-| `TState` *extends* `Record`\<`string`, [`Param`](Param.md)\> | `Record`\<`string`, [`Param`](Param.md)\> | - |
-| `TMatches` *extends* [`CreatedRouteOptions`](CreatedRouteOptions.md)[] | [`CreatedRouteOptions`](CreatedRouteOptions.md)[] | - |
-| `TContext` *extends* `RouteContext`[] | `RouteContext`[] | - |
-
-## Template
-
-The type or structure of the route's path.
-
-## Template
-
-The type or structure of the query parameters associated with the route.
+| `TUrl` *extends* [`Url`](Url.md) | [`Url`](Url.md) | The url the route resolves to, combined with any parents. Intersected into the route. |
+| `TMatches` *extends* [`CreatedRouteOptions`](CreatedRouteOptions.md)[] | [`CreatedRouteOptions`](CreatedRouteOptions.md)[] | The options of the route and its ancestors, indexed by depth. Name, meta, state, and context are all derived from this, including each route's views. |
diff --git a/docs/api/types/RouteAddLoader.md b/docs/api/types/RouteAddLoader.md
new file mode 100644
index 00000000..a101b54c
--- /dev/null
+++ b/docs/api/types/RouteAddLoader.md
@@ -0,0 +1,21 @@
+# Types: RouteAddLoader\
+
+```ts
+type RouteAddLoader = object;
+```
+
+Adds a loader to a route. Chainable to register multiple loaders, each exposed under its own name on
+the resolved route's `data`.
+
+## Type Parameters
+
+| Type Parameter | Default type |
+| ------ | ------ |
+| `TUrl` *extends* [`Url`](Url.md) | [`Url`](Url.md) |
+| `TMatches` *extends* [`CreatedRouteOptions`](CreatedRouteOptions.md)[] | [`CreatedRouteOptions`](CreatedRouteOptions.md)[] |
+
+## Properties
+
+| Property | Type | Description |
+| ------ | ------ | ------ |
+| `addLoader` | \<`TName`, `TGetter`\>(`load`, `options?`) => `AddLoaderReturn`\<`TUrl`, `TMatches`, `AddLoaderLoaders`\<`CurrentMatchLoaders`\<`TMatches`\>, `TName`, `ReturnType`\<`TGetter`\>\>\> | Adds a loader for this route. Loaders never block rendering, so their data is always a promise. |
diff --git a/docs/api/types/RouteAddView.md b/docs/api/types/RouteAddView.md
new file mode 100644
index 00000000..0bcf5440
--- /dev/null
+++ b/docs/api/types/RouteAddView.md
@@ -0,0 +1,21 @@
+# Types: RouteAddView\
+
+```ts
+type RouteAddView = object;
+```
+
+Adds a view (component + optional props getter) to a route. Chainable to register multiple views,
+including named views for named ``s.
+
+## Type Parameters
+
+| Type Parameter | Default type |
+| ------ | ------ |
+| `TUrl` *extends* [`Url`](Url.md) | [`Url`](Url.md) |
+| `TMatches` *extends* [`CreatedRouteOptions`](CreatedRouteOptions.md)[] | [`CreatedRouteOptions`](CreatedRouteOptions.md)[] |
+
+## Properties
+
+| Property | Type | Description |
+| ------ | ------ | ------ |
+| `addView` | \<`TComponent`, `TName`, `TGetter`\>(`component`, ...`options`) => `AddViewReturn`\<`TUrl`, `TMatches`, `AddViewProps`\<`CurrentMatchViews`\<`TMatches`\>, `TName`, `NewViewProps`\<[`Route`](Route.md)\<`TUrl`, `TMatches`\>, `TComponent`, `TGetter`\>\>\> | Adds a view for this route. |
diff --git a/docs/api/types/RouteCallbackContext.md b/docs/api/types/RouteCallbackContext.md
new file mode 100644
index 00000000..0dbb18f8
--- /dev/null
+++ b/docs/api/types/RouteCallbackContext.md
@@ -0,0 +1,24 @@
+# Types: RouteCallbackContext\
+
+```ts
+type RouteCallbackContext = object;
+```
+
+Context provided to a callback attached to a route — an `addView` props getter, or a loader. Sourced
+from the route: rejections/routes from the route's context, and the parent from the route's `matches`.
+
+## Type Parameters
+
+| Type Parameter |
+| ------ |
+| `TRoute` *extends* [`Route`](Route.md) |
+
+## Properties
+
+| Property | Type |
+| ------ | ------ |
+| `parent` | `RouteCallbackParent`\<`TRoute`\> |
+| `push` | [`RouterPush`](RouterPush.md)\<\[`TRoute`\] \| `RouteContextToRoute`\<`TRoute`\[`"context"`\]\>\> |
+| `reject` | [`RouterReject`](RouterReject.md)\<`RouteContextToRejection`\<`TRoute`\[`"context"`\]\>\> |
+| `replace` | [`RouterReplace`](RouterReplace.md)\<\[`TRoute`\] \| `RouteContextToRoute`\<`TRoute`\[`"context"`\]\>\> |
+| `update` | `RouteUpdate`\<[`ResolvedRoute`](ResolvedRoute.md)\<`TRoute`\>\> |
diff --git a/docs/api/types/RouteLoader.md b/docs/api/types/RouteLoader.md
new file mode 100644
index 00000000..bb133938
--- /dev/null
+++ b/docs/api/types/RouteLoader.md
@@ -0,0 +1,21 @@
+# Types: RouteLoader\
+
+```ts
+type RouteLoader = object;
+```
+
+A single loader: how to load its data, and how to prefetch it. Unlike a view, a loader always has a
+getter — a loader without one would have nothing to contribute.
+
+## Type Parameters
+
+| Type Parameter | Default type | Description |
+| ------ | ------ | ------ |
+| `TData` | `unknown` | What this loader's getter returns, carried so a route's data can be typed from it. |
+
+## Properties
+
+| Property | Type |
+| ------ | ------ |
+| `load` | `AnyFunction`\<`TData`\> |
+| `prefetch?` | [`PrefetchConfig`](PrefetchConfig.md) |
diff --git a/docs/api/types/RouteLoaders.md b/docs/api/types/RouteLoaders.md
new file mode 100644
index 00000000..504a5296
--- /dev/null
+++ b/docs/api/types/RouteLoaders.md
@@ -0,0 +1,7 @@
+# Types: RouteLoaders
+
+```ts
+type RouteLoaders = Record;
+```
+
+The loaders for a single route, keyed by loader name (the unnamed loader under 'default').
diff --git a/docs/api/types/RouteViews.md b/docs/api/types/RouteViews.md
new file mode 100644
index 00000000..0c6e2be4
--- /dev/null
+++ b/docs/api/types/RouteViews.md
@@ -0,0 +1,9 @@
+# Types: RouteViews
+
+```ts
+type RouteViews = Record>;
+```
+
+The views for a single route, keyed by view name (the unnamed view under 'default'). Indexed by depth in
+`route.views` — parallel to how `route.matches` indexes the matched options, which is where a route's id
+comes from at a given depth.
diff --git a/docs/api/types/RouterAssets.md b/docs/api/types/RouterAssets.md
index 2e5412bf..dd7725fc 100644
--- a/docs/api/types/RouterAssets.md
+++ b/docs/api/types/RouterAssets.md
@@ -14,30 +14,30 @@ type RouterAssets = object;
| Property | Type | Description |
| ------ | ------ | ------ |
-| `useLink` | `ReturnType`\<*typeof* `createUseLink`\> | A composition to export much of the functionality that drives RouterLink component. Also exports some useful context about routes relationship to current URL and convenience methods for navigating. **Param** The name of the route or a valid URL. **Param** If providing route name, this argument will expect corresponding params. **Param** [RouterResolveOptions](RouterResolveOptions.md) Same options as router resolve. |
+| `useLink` | `ReturnType`\<*typeof* `createUseLink`\> | A composition to export much of the functionality that drives RouterLink component. Also exports some useful context about routes relationship to current URL and convenience methods for navigating. **Param** **source** The name of the route or a valid URL. **Param** **params** If providing route name, this argument will expect corresponding params. **Param** **options** [RouterResolveOptions](RouterResolveOptions.md) Same options as router resolve. |
| `useQueryValue` | `ReturnType`\<*typeof* `createUseQueryValue`\> | A composition to access a specific query value from the current route. |
| `useRejection` | `ReturnType`\<*typeof* `createUseRejection`\> | A composition to access the rejection from the router. |
-| `useRoute` | `ReturnType`\<*typeof* `createUseRoute`\> | A composition to access the current route or verify a specific route name within a Vue component. This function provides two overloads: 1. When called without arguments, it returns the current route from the router without types. 2. When called with a route name, it checks if the current active route includes the specified route name. The function also sets up a reactive watcher on the route object from the router to continually check the validity of the route name if provided, throwing an error if the validation fails at any point during the component's lifecycle. **Template** A string type that should match route name of `RouterRouteName`, ensuring the route name exists. **Param** Optional. The name of the route to validate against the current active routes. **Throws** Throws an error if the provided route name is not valid or does not match the current route. |
+| `useRoute` | `ReturnType`\<*typeof* `createUseRoute`\> | A composition to access the current route or verify a specific route name within a Vue component. This function provides two overloads: 1. When called without arguments, it returns the current route from the router without types. 2. When called with a route name, it checks if the current active route includes the specified route name. The function also sets up a reactive watcher on the route object from the router to continually check the validity of the route name if provided, throwing an error if the validation fails at any point during the component's lifecycle. **Template** **TRouteName** A string type that should match route name of `RouterRouteName`, ensuring the route name exists. **Param** **routeName** Optional. The name of the route to validate against the current active routes. **Throws** Throws an error if the provided route name is not valid or does not match the current route. |
| `useRouter` | `ReturnType`\<*typeof* `createUseRouter`\> | A composition to access the installed router instance within a Vue component. **Throws** Throws an error if the router has not been installed, ensuring the component does not operate without routing functionality. |
## Components
| Property | Type | Description |
| ------ | ------ | ------ |
-| `RouterLink` | `ReturnType`\<*typeof* `createRouterLink`\> | A component to render a link to a route or any url. **Param** The props to pass to the router link component. |
-| `RouterView` | `ReturnType`\<*typeof* `createRouterView`\> | A component to render the current route's component. **Param** The props to pass to the router view component. |
+| `RouterLink` | `ReturnType`\<*typeof* `createRouterLink`\> | A component to render a link to a route or any url. **Param** **props** The props to pass to the router link component. |
+| `RouterView` | `ReturnType`\<*typeof* `createRouterView`\> | A component to render the current route's component. **Param** **props** The props to pass to the router view component. |
## Guards
| Property | Type | Description |
| ------ | ------ | ------ |
-| `isRoute` | `ReturnType`\<*typeof* `createIsRoute`\> | A guard to verify if a route or unknown value matches a given route name. **Param** The name of the route to check against the current route. |
+| `isRoute` | `ReturnType`\<*typeof* `createIsRoute`\> | A guard to verify if a route or unknown value matches a given route name. **Param** **routeName** The name of the route to check against the current route. |
## Hooks
| Property | Type | Description |
| ------ | ------ | ------ |
-| `onAfterRouteLeave` | [`AddAfterLeaveHook`](AddAfterLeaveHook.md)\<[`RouterRoutes`](RouterRoutes.md)\<`TRouter`\>, [`RouterRejections`](RouterRejections.md)\<`TRouter`\>\> | Registers a hook that is called after a route has been left. Must be called during setup. This can be used for cleanup actions after the component is no longer active, ensuring proper resource management. **Param** The hook callback function |
-| `onAfterRouteUpdate` | [`AddAfterUpdateHook`](AddAfterUpdateHook.md)\<[`RouterRoutes`](RouterRoutes.md)\<`TRouter`\>, [`RouterRejections`](RouterRejections.md)\<`TRouter`\>\> | Registers a hook that is called after a route has been updated. Must be called during setup. This is ideal for responding to updates within the same route, such as parameter changes, without full component reloads. **Param** The hook callback function |
-| `onBeforeRouteLeave` | [`AddBeforeLeaveHook`](AddBeforeLeaveHook.md)\<[`RouterRoutes`](RouterRoutes.md)\<`TRouter`\>, [`RouterRejections`](RouterRejections.md)\<`TRouter`\>\> | Registers a hook that is called before a route is left. Must be called from setup. This is useful for performing actions or cleanups before navigating away from a route component. **Param** The hook callback function |
-| `onBeforeRouteUpdate` | [`AddBeforeUpdateHook`](AddBeforeUpdateHook.md)\<[`RouterRoutes`](RouterRoutes.md)\<`TRouter`\>, [`RouterRejections`](RouterRejections.md)\<`TRouter`\>\> | Registers a hook that is called before a route is updated. Must be called from setup. This is particularly useful for handling changes in route parameters or query while staying within the same component. **Param** The hook callback function |
+| `onAfterRouteLeave` | [`AddAfterLeaveHook`](AddAfterLeaveHook.md)\<[`RouterRoutes`](RouterRoutes.md)\<`TRouter`\>, [`RouterRejections`](RouterRejections.md)\<`TRouter`\>\> | Registers a hook that is called after a route has been left. Must be called during setup. This can be used for cleanup actions after the component is no longer active, ensuring proper resource management. **Param** **AfterRouteHook** The hook callback function |
+| `onAfterRouteUpdate` | [`AddAfterUpdateHook`](AddAfterUpdateHook.md)\<[`RouterRoutes`](RouterRoutes.md)\<`TRouter`\>, [`RouterRejections`](RouterRejections.md)\<`TRouter`\>\> | Registers a hook that is called after a route has been updated. Must be called during setup. This is ideal for responding to updates within the same route, such as parameter changes, without full component reloads. **Param** **AfterRouteHook** The hook callback function |
+| `onBeforeRouteLeave` | [`AddBeforeLeaveHook`](AddBeforeLeaveHook.md)\<[`RouterRoutes`](RouterRoutes.md)\<`TRouter`\>, [`RouterRejections`](RouterRejections.md)\<`TRouter`\>\> | Registers a hook that is called before a route is left. Must be called from setup. This is useful for performing actions or cleanups before navigating away from a route component. **Param** **BeforeRouteHook** The hook callback function |
+| `onBeforeRouteUpdate` | [`AddBeforeUpdateHook`](AddBeforeUpdateHook.md)\<[`RouterRoutes`](RouterRoutes.md)\<`TRouter`\>, [`RouterRejections`](RouterRejections.md)\<`TRouter`\>\> | Registers a hook that is called before a route is updated. Must be called from setup. This is particularly useful for handling changes in route parameters or query while staying within the same component. **Param** **BeforeRouteHook** The hook callback function |
diff --git a/docs/api/types/RouterRoute.md b/docs/api/types/RouterRoute.md
index d4da8c7d..cb08efff 100644
--- a/docs/api/types/RouterRoute.md
+++ b/docs/api/types/RouterRoute.md
@@ -44,6 +44,7 @@ set query(value): void;
| Property | Modifier | Type | Description |
| ------ | ------ | ------ | ------ |
+| `data` | `readonly` | `RouteDataOf`\<`TRoute`\[`"matches"`\]\> | What the route's loaders resolve to, keyed by loader name. A route whose only loader is unnamed exposes that loader's data here directly. |
| `hash` | `readonly` | `string` | Hash value of the route. |
| `href` | `readonly` | `TRoute`\[`"href"`\] | String value of the resolved URL. |
| `id` | `readonly` | `TRoute`\[`"id"`\] | Unique identifier for the route, generated by router. |
diff --git a/docs/api/types/RouterViewPropsGetter.md b/docs/api/types/RouterViewPropsGetter.md
index b6fb4c32..a617815e 100644
--- a/docs/api/types/RouterViewPropsGetter.md
+++ b/docs/api/types/RouterViewPropsGetter.md
@@ -14,7 +14,7 @@ type RouterViewPropsGetter = (route, context) => MaybePromise\> |
+| `route` | [`ResolvedRoute`](ResolvedRoute.md)\<[`ToRoute`](ToRoute.md)\<`TOptions`\>\> & [`WithData`](WithData.md)\<[`ToRoute`](ToRoute.md)\<`TOptions`\>\> |
| `context` | [`PropsCallbackContext`](PropsCallbackContext.md)\<[`ToRoute`](ToRoute.md)\<`TOptions`\>, `TOptions`\> |
## Returns
diff --git a/docs/api/types/ToRoute.md b/docs/api/types/ToRoute.md
index 8a412389..d0fce76b 100644
--- a/docs/api/types/ToRoute.md
+++ b/docs/api/types/ToRoute.md
@@ -1,7 +1,7 @@
# Types: ToRoute\
```ts
-type ToRoute = CreateRouteOptions extends TOptions ? Route : TOptions extends object ? Route, TOptions["hoist"] extends true ? ToUrl : CombineUrl>, CombineMeta, ToMeta>, CombineState, ToState>, ToMatches extends TProps ? undefined : TProps>, [...ToRouteContext, ...ToRouteContext]> : Route, ToUrl>, ToMeta, ToState, ToMatches extends TProps ? undefined : TProps>, ToRouteContext>;
+type ToRoute = CreateRouteOptions extends TOptions ? Route : Route, ToRouteMatches>;
```
## Type Parameters
diff --git a/docs/api/types/WithData.md b/docs/api/types/WithData.md
new file mode 100644
index 00000000..d143d643
--- /dev/null
+++ b/docs/api/types/WithData.md
@@ -0,0 +1,21 @@
+# Types: WithData\
+
+```ts
+type WithData = object;
+```
+
+A resolved route whose loaders' data is available. Only the route being navigated to has data: a route
+the router merely resolved is not being loaded, so data on it could never settle. The current route and
+a props getter's route have it, `router.resolve` and hooks do not.
+
+## Type Parameters
+
+| Type Parameter | Default type |
+| ------ | ------ |
+| `TRoute` *extends* [`Route`](Route.md) | [`Route`](Route.md) |
+
+## Properties
+
+| Property | Type | Description |
+| ------ | ------ | ------ |
+| `data` | `RouteDataOf`\<`TRoute`\[`"matches"`\]\> | What the route's loaders resolve to, keyed by loader name. A route whose only loader is unnamed exposes that loader's data here directly. Always promises, since loaders never block rendering. |