Send using meta

If I use go with getToPath and add a custom meta element, is that suppose to be shown in the URL?
2 Replies
kapa.ai
kapa.ai4d ago
Hi @Todilo. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- If you use go with getToPath and add a custom property to the meta object, only those meta properties that correspond to route parameters (e.g., :id, :authorId) will be used to fill the URL path. Other custom properties in meta will not appear in the URL as query parameters or path segments—they are used internally for things like data fetching or passing additional context, not for URL generation. For example, if your route is defined as /posts/:authorId/:id/edit and you use:
getToPath({
resource: "posts",
action: "edit",
meta: { id: 1, authorId: 2, custom: "value" },
})
getToPath({
resource: "posts",
action: "edit",
meta: { id: 1, authorId: 2, custom: "value" },
})
The resulting URL will be /posts/2/1/edit. The custom: "value" part of meta will not appear in the URL—it is not reflected in the path or as a query parameter by default. Only parameters matching the route pattern are used in the URL composition. This is confirmed in the documentation for useGetToPath and in practical usage examples, which show only route parameters being reflected in the URL, not arbitrary meta fields useGetToPath. If you want to add query parameters to the URL (e.g., ?activeTab=5), you should use the query property of the go function, not meta. For example:
go({
to: getToPath({ resource: "posts", action: "show", meta: { id: 5 } }),
query: { activeTab: 5 },
});
go({
to: getToPath({ resource: "posts", action: "show", meta: { id: 5 } }),
query: { activeTab: 5 },
});
This will result in a URL like /posts/show/5?activeTab=5 navigate to show with custom params. In summary:
- meta is used for filling route parameters in the path, not for adding arbitrary data to the URL. - To add query parameters, use the query property of the go function. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4d ago
<@207945811592478720> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?