HttpStatusCode
HttpStatusCode is a component that 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
- On the server,
event.response.statusis set tocode. event.response.statusTextis set totext.- During cleanup, the response status resets to
200when the event is not complete and the native event has not been handled. - Client rendering returns
null.
Examples
Basic usage
import { HttpStatusCode } from "@solidjs/start";
export default function NotFound() { return <HttpStatusCode code={404} text="Not Found" />;}