{"id":28857182,"url":"https://github.com/falkz/zod-search-params","last_synced_at":"2026-01-20T16:42:58.952Z","repository":{"id":299885423,"uuid":"1004255532","full_name":"FalkZ/zod-search-params","owner":"FalkZ","description":"Type-safe URL search parameters using Zod schemas","archived":false,"fork":false,"pushed_at":"2025-06-18T19:26:46.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-18T20:28:31.263Z","etag":null,"topics":["query-params-parsing","url-search-params","zod","zod-validation"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@falkz/zod-search-params","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FalkZ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-18T10:54:48.000Z","updated_at":"2025-06-18T19:32:38.000Z","dependencies_parsed_at":"2025-06-18T20:30:24.109Z","dependency_job_id":"8d946533-77b9-46aa-a422-f26c12ecd838","html_url":"https://github.com/FalkZ/zod-search-params","commit_stats":null,"previous_names":["falkz/zod-search-params"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/FalkZ/zod-search-params","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FalkZ%2Fzod-search-params","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FalkZ%2Fzod-search-params/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FalkZ%2Fzod-search-params/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FalkZ%2Fzod-search-params/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FalkZ","download_url":"https://codeload.github.com/FalkZ/zod-search-params/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FalkZ%2Fzod-search-params/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260857501,"owners_count":23073448,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["query-params-parsing","url-search-params","zod","zod-validation"],"created_at":"2025-06-20T01:14:56.963Z","updated_at":"2026-01-20T16:42:58.946Z","avatar_url":"https://github.com/FalkZ.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @falkz/zod-search-params\n\nType-safe URL search parameters using Zod schemas.\n\n## Installation\n\n```bash\nnpm install @falkz/zod-search-params zod\n```\n\n## Quick Start\n\n```typescript\nimport { z } from \"zod/v4\";\nimport { searchParamsObject, toSearchParams } from \"@falkz/zod-search-params\";\n\nconst schema = searchParamsObject({\n  query: z.string(),\n  page: z.number(),\n  limit: z.number().optional(),\n  active: z.boolean(),\n});\n\n// Parse\nconst params = schema.parse(\"?query=hello\u0026page=1\u0026active=true\");\n// { query: 'hello', page: 1, limit: undefined, active: true }\n\n// Serialize\nconst urlParams = toSearchParams({ query: \"world\", page: 2, active: false });\n// URLSearchParams { 'query' =\u003e 'world', 'page' =\u003e '2' }\n```\n\n## API\n\n### Creating a Schema\n\n`searchParamsObject()` behaves the same way as `z.object()`. This means as long as you use [supported values](#supported) you can create the schema in the same way as you are used to from zod.\n\n```typescript\nimport { z } from \"zod/v4\";\nimport { searchParamsObject } from \"@falkz/zod-search-params\";\n\nconst schema = searchParamsObject({\n  name: z.string(),\n  age: z.number(),\n  active: z.boolean().optional(),\n});\n\ntype InferredType = z.infer\u003ctypeof schema\u003e;\n\nconst typedObject = schema.parse(\"name=john\u0026age=25\u0026active=true\");\n// or\nconst typedObject = schema.parse(new URLSearchParams(\"name=john\u0026age=25\"));\n// or\nconst typedObject = schema.parse(window.location.search);\n```\n\n### \u003cspan id=\"supported\"\u003eSupported Values\u003c/span\u003e\n\nThese are all the values the `searchParamsObject` accepts:\n\n- [`z.string()`, `z.number()`, `z.bigint()`, `z.boolean()`](https://zod.dev/api#primitives)\n- [`z.literal()`](https://zod.dev/api#literals)\n- [`z.email()`, `z.url()`, `z.uuid()`, etc.](https://zod.dev/api#string-formats)\n- [`z.enum()`](https://zod.dev/api#enums)\n- [`z.templateLiteral()`](https://zod.dev/api#template-literals)\n- [`.optional()` modifier](https://zod.dev/api#optionals)\n\nIf the value is not supported, typescript will let you know that you passed in a value that does not work.\n\n### Serializing to URLSearchParams\n\n`toSearchParams` converts an object to URLSearchParams. When parsed again by `searchParamsObject` the same object will be recreated.\n\n```typescript\nimport { toSearchParams } from \"@falkz/zod-search-params\";\n\n// create new params:\nconst params = toSearchParams({\n  query: \"hello\",\n  page: 1,\n  active: true,\n  disabled: false,\n  empty: undefined,\n});\n\n// or update existing params:\nconst updatedParams = toSearchParams(\n  {\n    query: \"hello\",\n    page: 1,\n    active: true,\n    disabled: false,\n    empty: undefined,\n  },\n  window.location.search,\n);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffalkz%2Fzod-search-params","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffalkz%2Fzod-search-params","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffalkz%2Fzod-search-params/lists"}