T
TanStack3mo ago
wise-white

Best way to get path slug in createServerFn?

I have a server function that needs to get the projectId from my path /dashboard/project/1 At the moment I am using react-query and I am getting the projectId from the cliente with useParams and passing the id as a data parameter to the server function. But I would like to know if there is a better way.
4 Replies
other-emerald
other-emerald3mo ago
which other way would there be? if you want to pass something to a server function, you need to pass it as a param
wise-white
wise-whiteOP3mo ago
Does a middleware could get the Slug and put it in the context?
other-emerald
other-emerald3mo ago
potentially. but you must be aware that you could execute a server function whilst on any route
wise-white
wise-whiteOP3mo ago
Ok, I see. Thanks

Did you find this page helpful?