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•3mo 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-whiteOP•3mo ago
Does a middleware could get the Slug and put it in the context?
other-emerald•3mo ago
potentially. but you must be aware that you could execute a server function whilst on any route
wise-whiteOP•3mo ago
Ok, I see. Thanks