Skip to content

Conversation

@lazarv
Copy link
Owner

@lazarv lazarv commented Nov 27, 2025

This PR fixes redirects when using RSC rendering, including redirecting when using navigation with <Link> component from @lazarv/react-server/navigation.

As redirects are throwing a redirect error, this means that this PR implements enhanced error handling for RSC payloads, handling the request gracefully when an error is included in the RSC payload. In case there's a client-side error during the RSC request, a new RSC payload is constructed with the error included.

The redirect() function is now aware of what type of response is expected using the rendering context and sets an RSC payload as the redirect response for RSC requests.

The file-system based router was fixed to handle middleware redirects when using a web standard Response.redirect response with an RSC context. When detected, the response will be changed to an RSC redirect error.

Client-side redirect handling is now aware about external redirects and in case of the redirect location is external, it fires a browser page navigation using replace.

Error boundary components are now handling browser history change with a page reload when needed, to re-render the page after navigation.

The file-router example app was extended to include various redirect use cases, and the test suite for the example app was also extended to test redirects too.

@lazarv lazarv changed the title fix: redirect when using rsc fix: redirect when using RSC Nov 27, 2025
@lazarv lazarv merged commit 35dbbff into main Dec 14, 2025
94 of 97 checks passed
@lazarv lazarv deleted the fix/redirect-rsc branch December 14, 2025 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants