API/RouterAdapter
RouterAdapter
typesrc/types/router-adapter.type.ts3 members
What useQubeeList needs from a router: where the page is, and how to go somewhere
else.
Build it on every render from the router’s own hooks, so reactivity comes from the router; the
hook never relies on the object’s identity. useBrowserAdapter is one for apps without a
router, and the entries @qubeejs/react/react-router, @qubeejs/react/tanstack-router and
@qubeejs/react/next ship one for each of those routers. For any other router, write the hook
and hand it to createAdapterProvider.
Import
Section titled “Import”import type { RouterAdapter } from '@qubeejs/react';Definition
Section titled “Definition”type RouterAdapter = { … }Members
Section titled “Members”| Member | Type | Description |
|---|---|---|
navigate |
(href: string, options: AdapterNavigateOptions) => void |
Go to href: a pathname plus an optional ?query, as buildListHref builds it. |
pathname |
string |
The current pathname, without the query. |
search |
SearchParamsInput |
The current query: URLSearchParams, a string with or without ?, or Next’s record. |
Example
Section titled “Example”function useMyRouterAdapter(): RouterAdapter { const router = useMyRouter();
return { navigate: (href, { replace }) => (replace ? router.replace(href) : router.push(href)), pathname: router.pathname, search: router.search, };}