HttpStatusCode
HttpStatusCode sets the response status code on the server.
Import
import { HttpStatusCode } from "@solidjs/start";Type
interface HttpStatusCodeProps { code: number; text?: string;}
const HttpStatusCode: (props: HttpStatusCodeProps) => null;Props
code
- Type:
number - Optional: No
HTTP status code assigned to the response.
text
- Type:
string - Optional: Yes
HTTP status text assigned to the response.
Behavior
event.response.statusis set tocodeandevent.response.statusTexttotext.- Cleanup resets the status to
200when the event is not complete. - Client rendering returns
null.
Examples
Basic usage
import { HttpStatusCode } from "@solidjs/start";
export default function NotFound() { return <HttpStatusCode code={404} />;}