Reference
Redirects and Headers
Use standard HTTP redirects and Location headers when the server needs to move the browser.
How it works
RGX uses `fetch`, so a normal HTTP redirect works the same way it would for any browser request: the client follows the final URL, `response.redirected` becomes true, and `response.url` points at the destination.
The runtime then uses that final URL for history, which keeps the navigation stack aligned with the server decision.
Go example
When a route needs to send the user somewhere else, return a 3xx response with a `Location` header. In Go, `http.Redirect` handles both pieces for you.
func loginRequired(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/login", http.StatusSeeOther)
}
JSON header example
Docs, tests, and examples can show the response metadata as JSON even though the real transport is still HTTP headers.
That makes the redirect target and the RGX-specific follow-up headers easy to scan in one block.
{
"status": 303,
"headers": {
"Location": "/login",
"Recyclr-Use-Presets": "dashboard modal",
"Recyclr-Event": "updated"
}
}
When to use it
Use redirects for auth gates and post-submit transitions where the server already knows the next page.
After a POST, a `303 See Other` is usually the safest default because it tells the browser to continue with a GET on the destination page.
- Authenticate, then redirect to the intended page.
- Normalize routes without adding client-side logic.
- Keep application flow under server control while RGX swaps the content.