query-guard
v0.1.3
Published
Type-safe URL search params (querystring) state (alias of @liha-labs/query-guard).
Downloads
350
Maintainers
Readme
query-guard (alias)
This is a convenience alias of @liha-labs/query-guard.
It re-exports the core-only API (no React or Zod dependencies).
ESM-only
Exports import + types via exports. No CommonJS build.
Install
pnpm add query-guardUsage (Core)
import { createBrowserAdapter, createQueryGuard } from 'query-guard'
const resolver = {
resolve: ({ raw }) => ({ value: { q: raw.q ?? '' } }),
serialize: (value) => ({ q: value.q }),
}
const guard = createQueryGuard({
adapter: createBrowserAdapter(),
resolver,
defaultValue: { q: '' },
})
guard.set({ q: 'hello' })React Usage
Use the dedicated React package:
pnpm add @liha-labs/query-guard-react reactSee the root README for a Provider + hook example.
Zod Usage
Use the dedicated resolver package:
pnpm add @liha-labs/query-guard-resolvers zodSSR / History Notes
createBrowserAdapteris browser-only and throws whenwindowis undefined.createBrowserAdaptersubscribes only topopstate(externalpushState/replaceStatedoes not notify). See the root README for full details.
