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.status is set to code.
  • event.response.statusText is set to text.
  • During cleanup, the response status resets to 200 when 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" />;
}
Last updated: 5/6/26, 4:10 AMEdit this pageReport an issue with this page