Returning responses
Edit this pageIn SolidStart, it is possible to return a Response object from a server function.
solid-router
knows how to handle certain responses with its cache
and action
APIs.
For Typescript, when returning a response using solid-routers
's redirect
, reload
, or json
helpers, they will not impact the return value of the server function.
While we suggest depending on the type of the function to handle errors differently, you can always return or throw a response.
Examples
In the following example, the hello
function will return a value of type Promise<{ hello: string }>
:
However, in this example, since redirect
and reload
return never
as their type, getUser
can only return a value of type Promise<User>
: