isMiniRedirect()
isMiniRedirect() is a type guard for the control-flow value thrown by redirectTo(). It accepts any value and returns true only for a MiniRedirect.
Custom Rendering Integrations
mini() catches MiniFW redirects automatically, so most applications do not need this helper. Use it only when you invoke rendering yourself and need to convert the thrown value into a response:
import { isMiniRedirect } from "@calvinbonner/minifw/helpers";
try {
const markup = await renderAccount();
return new Response(markup, { headers: { "content-type": "text/html" } });
} catch (caught) {
if (isMiniRedirect(caught)) return caught.response;
throw caught;
}
After the guard returns true, TypeScript knows the value has its redirect response, including its destination and HTTP status.
What It Recognizes
The guard returns false for ordinary exceptions and for arbitrary values. It specifically identifies MiniFW's MiniRedirect class rather than validating objects that merely have a response property.
Use redirectTo() for a redirect chosen during a page(), partial(), or layout() render. For a route that always redirects, use redirect() instead.