Open brillout opened 4 months ago
Deprioritizing, as per https://github.com/vikejs/vike-react/pull/123#issuecomment-2196236446.
Is this not supposed to work already?
In my test project, I implemented vike-node
and am using throw redirect() in a React Component I have, but only in SSR in order to redirect to another page when the user isn't logged-in, and it seems to work fine.
@simplecommerce Yes it already works if the onRenderHtml()
and onRenderClient()
hooks receive the exception thrown by throw redirect()
/ throw render()
, and if you aren't using HTML streaming. Because it isn't clear what should happen when throw redirect()
/ throw render()
is called during HTML Streaming (will browsers respect the redirect header after the HTML stream has started?), I recommend defining user redirections on a page level instead of a component level.
Description
In principle, it should be possible to use
throw render()
andthrow redirect()
inside UI components.For this to work,
vike-{react,vue,solid}
need to catch the exception and then re-throw it inside theonRenderHtml()
/onRenderClient()
hook, so that the exception propagates to Vike.Contribution welcome.