Skip to main content
This hook may not be available in the current version of Refine. Please verify with the official documentation or source code.
The useRouterType hook is intended to return information about the router type being used in your Refine application.

Usage

import { useRouterType } from "@refinedev/core";

const routerType = useRouterType();

Return Value

The hook is expected to return the type of router currently in use, such as:
  • "legacy" - Legacy router implementation
  • "new" - New router implementation
  • undefined - No router configured

Example

import { useRouterType } from "@refinedev/core";

const MyComponent = () => {
  const routerType = useRouterType();

  return (
    <div>
      <p>Router Type: {routerType || "Not configured"}</p>
    </div>
  );
};

Conditional Behavior Based on Router

import { useRouterType } from "@refinedev/core";

const MyComponent = () => {
  const routerType = useRouterType();

  if (routerType === "legacy") {
    return <div>Using legacy router</div>;
  }

  if (routerType === "new") {
    return <div>Using new router</div>;
  }

  return <div>No router configured</div>;
};

Notes

  • This hook helps determine which router implementation is active
  • Useful for maintaining backward compatibility
  • Can be used to conditionally render components based on router type

See Also

Build docs developers (and LLMs) love