Type Alias: TanStackRouterLike
API / @xmachines/play-tanstack-react-router / TanStackRouterLike
type TanStackRouterLike = object;Defined in: play-tanstack-router/src/tanstack-router-bridge-base.ts:39
The type-only interface of the TanStack Router surface that
TanStackRouterBridgeBase uses. An instance of @tanstack/react-router and an
instance of @tanstack/solid-router both satisfy it.
Properties
history
history: object;Defined in: play-tanstack-router/src/tanstack-router-bridge-base.ts:72
location
location: object;The current location. createRouter() fills it from window.location, before
router.load(). It is always available in the browser.
router.state.location has a value only after router.load(), and that value
can be old.
location.pathname
pathname: string;location.search?
optional search?: string;subscribe()
subscribe(handler): () => void;Parameters
| Parameter | Type |
|---|---|
handler | (event) => void |
Returns
() => void
options?
optional options?: object;Defined in: play-tanstack-router/src/tanstack-router-bridge-base.ts:58
The options of the router. The bridge reads parseSearch only.
TanStack owns the encoding of a query: its default stringifySearch writes each
value through JSON.stringify, so a plain string arrives in the URL with quotes
around it. parseSearch is the inverse, and it is therefore the only correct way
to turn a query string of the URL into the search object that navigate
accepts. A router double may hold neither.
parseSearch()?
optional parseSearch(search): Record<string, unknown>;Parameters
| Parameter | Type |
|---|---|
search | string |
Returns
Record<string, unknown>
Methods
load()?
optional load(): void | Promise<void>;Defined in: play-tanstack-router/src/tanstack-router-bridge-base.ts:71
Runs the TanStack route matching and the loaders again for the current location.
This method is optional. The bridge calls it after every navigation. The matching
and the loaders therefore stay correct, also when no <RouterProvider> is
mounted.
The real implementation returns a promise. watchRouterChanges waits for that
promise before it synchronizes the actor, because router.load() is the only
public point that also runs router.updateLatestLocation(). See
watchRouterChanges for the reason. A test double may return void, and the
bridge then synchronizes synchronously.
Returns
void | Promise<void>
navigate()
navigate(args): void;Defined in: play-tanstack-router/src/tanstack-router-bridge-base.ts:48
Navigates to a location. search carries the query of the target.
The bridge passes search whenever the route of the actor holds a query. A
navigate({ to }) call with no search makes TanStack rebuild the query from
validateSearch({}) of the matched route, and a route that injects a default
then commits a different href than the bridge asked for.
Parameters
| Parameter | Type |
|---|---|
args | { search?: Record<string, unknown>; to: string; } |
args.search? | Record<string, unknown> |
args.to | string |
Returns
void