parseAsBoolean
const parseAsBoolean: Parser<boolean>;Defined in: tanstack/core/built-in-parsers.ts:115
"true" ⇄ true, "false" ⇄ false. Case-insensitive on read
("TRUE" → true), like nuqs.
Like nuqs, it never returns null for a present key: any value other than
"true" (?on=yes, ?on=1) reads as false, so clearOnInvalid never
strips it. Use parseAsStringLiteral(["true", "false"]) or a custom
parser if junk should be rejected.
Example
Section titled “Example”import { parseAsBoolean } from "@xtandard/lib/tanstack";
parseAsBoolean.parse("true"); // → trueparseAsBoolean.parse("TRUE"); // → trueparseAsBoolean.parse("yes"); // → falseparseAsBoolean.serialize(true); // → "true"
const showArchived = parseAsBoolean.withDefault(false);