#Is there a lifecycle hook that runs before validateSearch?

4 messages · Page 1 of 1 (latest)

urban thunder
#

Two scenarios:

  1. Page with required params, but the params can only be validated asynchronously, or have asynchronous fallback values. Right now we're abusing the layout route (or __root in this case specifically) to do the search sanitation in beforeLoad, so the route can run its validateSearch on proper values. It feels very dirty and constraining.

  2. Page with a guard based on search params. Do not allow entering page A without certain params set, if they are missing - redirect to page B. Since validateSearch cannot throw redirect AND it also runs before beforeLoad, we have to do the same layout (or __root) shenanigans.

Both scenarios could be solved easily if we had another lifecycle method that runs before validateSearch. What do you think?

The alternative is to allow validateSearch to be async and allow throwing redirects, but that can be hard or even out of scope.

stiff mantle
#

right now we don't have that.

#

can you please describe your workaround using code examples in a github discussion feature request ?

urban thunder
#

will do 🫡