redirect

redirect is a helper to create redirect Response objects.
tsx
redirect("/my-next-destination");
tsx
redirect("/my-next-destination");


Usage

redirect is a helper for creating responses objects with the Location header and a redirect status code. It is useful for sending redirects from createServerData$, createServerAction$ and their variants. API Routes can also use it to send redirects.

tsx
import { redirect } from "solid-start/server";
 
export function GET() {
return redirect('/some/other/path');
}
tsx
import { redirect } from "solid-start/server";
 
export function GET() {
return redirect('/some/other/path');
}

Reference

redirect(location: string)

Use redirect('/somewhere') to create a Response that's going to redirect the user to /somewhere. It will set the Location header. Basically wherever a Response is expected, it is useful inside.

For example:

ts
import { redirect } from "solid-start/server";
 
const response = redirect('/somewhere');
ts
import { redirect } from "solid-start/server";
 
const response = redirect('/somewhere');