Get params without including it in file name.
Hi!
I have an URL like that:
http://localhost:5173/auth/login?error=already_exists
I want to get the error value without having the $error in my file name.3 Replies
fascinating-indigo•2y ago
You can use a
useSearch() hook to pull out the search parameter from the URL for that route.
https://tanstack.com/router/latest/docs/framework/react/guide/search-paramsSearch Params | TanStack Router Docs
Similar to how TanStack Query made handling server-state in your React applications a breeze, TanStack Router aims to unlock the power of URL search params in your applications.
Why not just use URLSearchParams?
fascinating-indigo•2y ago
It'd be best to define your validation schema for the search params to get type-safe usage.
vicious-goldOP•2y ago
okay ! 🙂