redirect
redirect
is a helper to create redirect Response
objects.
tsx
("/my-next-destination"); redirect
tsx
("/my-next-destination"); redirect
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 {} from "solid-start/server"; redirect export function() { GET return('/some/other/path'); redirect }
tsx
import {} from "solid-start/server"; redirect export function() { GET return('/some/other/path'); redirect }
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:
- API Routes
server$
functions- Middleware
ts
import {} from "solid-start/server"; redirect const= response ('/somewhere'); redirect
ts
import {} from "solid-start/server"; redirect const= response ('/somewhere'); redirect