- Based on TanStack Query
queryOptionsAPI - Typesafe: uses Standard Schema under the hood
- Ergonomic: core API, with adapters for common frameworks
- Isomorphic: define once, use anywhere
- Core (web)
- Next.js
- TanStack Start
- Remix
- React Router v7
import { cookieOptions } from "@standard-cookie/next"
import { z } from "zod"
export const settingsCookieOptions = cookieOptions({
name: "theme",
path: "/",
schema: z.object({
foo: z.boolean(),
bar: z.boolean(),
}),
})By default, cookie value is serialized using JSON.stringify and JSON.parse.
TODO: document
- Only when the schema output type extends
string - Neat for reading cookies in other origins or integrating with third parties that expect a tring instead of serialized gibberish
export const themeCookieOptions = cookieOptions({
name: "theme",
path: "/",
schema: z.union([z.literal("light"), z.literal("dark")]),
serializer: {
encode: (data) => data,
decode: (data) => data,
},
})