Skip to main content
Version: 4.xx.xx


useGetToPath is a hook that returns a function that composes the URL for the given resource and the action by using the URL parameters and the meta property if provided.

This is useful when you want to navigate to a specific action of a resource and you want to have the URL to be composed automatically.


import { useGetToPath, useGo } from "@refinedev/core";

// Let's assume that we have a resource named `posts` and the `edit` action path is `/:authorId/posts/:id/edit`

const MyComponent = () => {
const getToPath = useGetToPath();

const go = useGo();

return (
onClick={() => {
to: getToPath({
resource: "posts",
action: "edit",
meta: {
id: 1,
authorId: 2,
Go To Edit Post

/* ... */

The authorId and id parameters will be inferred from the route if they are present in the URL. If you want to explicitly set the value of a parameter, you can use the meta property.



This is the name of the resource that you want to navigate to.


This is the name of the action that you want to navigate to.


This is the meta object that you want to use to compose the URL. It will be merged with the params object that is parsed from the URL.


This is a boolean value that indicates whether the legacy URL format should be used or not. If it is set to true, the URL will be composed for the legacy routers. Default value is false.