HttpHeader
HttpHeader is a component that sets or appends a response header on the server.
Import
import { HttpHeader } from "@solidjs/start";Type
interface HttpHeaderProps { name: string; value: string; append?: boolean;}
const HttpHeader: (props: HttpHeaderProps) => null;Props
name
- Type:
string - Optional: No
Header name.
value
- Type:
string - Optional: No
Header value.
append
- Type:
boolean - Optional: Yes
Controls whether the value is appended instead of set.
Behavior
- On the server, the current request event is read.
- Truthy
appendcallsevent.response.headers.append(name, value), while falsyappendcallsevent.response.headers.set(name, value). - During cleanup, its own header value is removed unless the event has already completed or been handled.
- Client rendering returns
null.
Examples
Basic usage
import { HttpHeader } from "@solidjs/start";
export default function Page() { return <HttpHeader name="cache-control" value="max-age=60" />;}