Skip to content
API/RouterAdapter

RouterAdapter

type
src/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 type { RouterAdapter } from '@qubeejs/react';
type RouterAdapter = { … }
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.
function useMyRouterAdapter(): RouterAdapter {
const router = useMyRouter();
return {
navigate: (href, { replace }) => (replace ? router.replace(href) : router.push(href)),
pathname: router.pathname,
search: router.search,
};
}

AdapterNavigateOptions