T
TanStack6mo ago
vicious-gold

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
stormy-gold
stormy-gold6mo 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
vicious-gold
vicious-goldOP6mo ago
Does a middleware could get the Slug and put it in the context?
stormy-gold
stormy-gold6mo ago
potentially. but you must be aware that you could execute a server function whilst on any route
vicious-gold
vicious-goldOP6mo ago
Ok, I see. Thanks

Did you find this page helpful?