Why not use a Stateless option and go with a param i.e. redirect(/login?error=${encodeURIComponent(error.message)})
Then on the client-side useSearchParams#get('error')
, then if you want to be fancy, you can mask the URL on the client-side and replace the URL in order to keep it clean.