{"id":25881104,"url":"https://github.com/vdustr/nanostores-qs","last_synced_at":"2025-03-02T14:32:59.215Z","repository":{"id":280255709,"uuid":"940997793","full_name":"VdustR/nanostores-qs","owner":"VdustR","description":"A reactive querystring manager using nanostores","archived":false,"fork":false,"pushed_at":"2025-03-02T10:03:53.000Z","size":337,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-02T10:26:56.825Z","etag":null,"topics":["nanostores","persistent","qs","querystring","search","searchparams"],"latest_commit_sha":null,"homepage":"http://vdustr.dev/nanostores-qs/","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/VdustR.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}},"created_at":"2025-03-01T08:28:34.000Z","updated_at":"2025-03-02T10:03:30.000Z","dependencies_parsed_at":"2025-03-02T10:27:17.088Z","dependency_job_id":"6925b7ac-ee72-4262-baca-17280e414e30","html_url":"https://github.com/VdustR/nanostores-qs","commit_stats":null,"previous_names":["vdustr/nanostore-qs"],"tags_count":0,"template":false,"template_full_name":"VdustR/template-aio","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VdustR%2Fnanostores-qs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VdustR%2Fnanostores-qs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VdustR%2Fnanostores-qs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VdustR%2Fnanostores-qs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VdustR","download_url":"https://codeload.github.com/VdustR/nanostores-qs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241522313,"owners_count":19976252,"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":["nanostores","persistent","qs","querystring","search","searchparams"],"created_at":"2025-03-02T14:32:58.619Z","updated_at":"2025-03-02T14:32:59.201Z","avatar_url":"https://github.com/VdustR.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @vp-tw/nanostores-qs\n\nA reactive querystring manager using nanostores.\n\n\u003e [!WARNING]\n\u003e\n\u003e ## WIP\n\u003e\n\u003e Documentation generated using Copilot Edits.\n\n## Features\n\n- 🔄 Reactive query string parameters that stay in sync with the URL\n- 🔍 Type-safe parameter definitions with encoding/decoding support\n- 🧩 Works with both native URLSearchParams and custom query string libraries (like `qs`)\n- 🪝 Easy integration with frameworks via [nanostores](https://github.com/nanostores/nanostores)\n- 🔢 Support for arrays, numbers, dates, and custom types\n- ✅ Validation using libraries like Zod\n- 📚 Flexible API for single or multiple parameters\n\n## Installation\n\n```bash\n# npm\nnpm install @vp-tw/nanostores-qs @nanostores/react nanostores\n\n# yarn\nyarn add @vp-tw/nanostores-qs @nanostores/react nanostores\n\n# pnpm\npnpm install @vp-tw/nanostores-qs @nanostores/react nanostores\n```\n\n## Usage\n\n```ts\nimport { createQsUtils } from \"@vp-tw/nanostores-qs\";\n\nconst qsUtils = createQsUtils(/* Options */);\n```\n\n## Basic Usage\n\n```tsx\nimport { useStore } from \"@nanostores/react\";\nimport { createQsUtils } from \"@vp-tw/nanostores-qs\";\n\n// Create query string utilities\nconst qsUtils = createQsUtils();\n\n// Create a store for a single parameter\nconst pageStore = qsUtils.createSearchParamStore(\"page\", {\n  decode: Number,\n  encode: String,\n  defaultValue: 1,\n});\n\n// In React component\nfunction Pagination() {\n  const page = useStore(pageStore.$value);\n\n  return (\n    \u003cdiv\u003e\n      Current page: {page}\n      \u003cBottom onClick={() =\u003e pageStore.update(page + 1)}\u003eNext\u003c/Bottom\u003e\n    \u003c/div\u003e\n  );\n}\n```\n\n## Advanced Usage\n\nMultiple Parameters\n\n```tsx\nconst filtersStore = qsUtils.createSearchParamsStore((defineSearchParam) =\u003e ({\n  search: defineSearchParam({ defaultValue: \"\" }),\n  category: defineSearchParam({ isArray: true }),\n  minPrice: defineSearchParam({\n    decode: Number,\n    encode: String,\n  }),\n  maxPrice: defineSearchParam({\n    decode: Number,\n    encode: String,\n  }),\n  sortBy: defineSearchParam({\n    defaultValue: \"newest\",\n  }),\n}));\n\n// In React component\nfunction Filters() {\n  const filters = useStore(filtersStore.$values);\n\n  const updateFilters = (newFilters) =\u003e {\n    filtersStore.updateAll(\n      {\n        ...filters,\n        ...newFilters,\n      },\n      {\n        replace: true, // Replace current history state instead of adding new entry\n      },\n    );\n  };\n\n  return \u003cdiv\u003e...\u003c/div\u003e;\n}\n```\n\nUsing Zod for Validation\n\n```ts\nimport { z } from \"zod\";\n\nconst SortOptionSchema = z.enum([\"newest\", \"price_asc\", \"price_desc\"]);\n\nconst sortStore = qsUtils.createSearchParamStore(\"sort\", {\n  decode: SortOptionSchema.parse,\n  defaultValue: \"newest\",\n});\n```\n\nCustom Query String Library\n\n```ts\nimport { parse, stringify } from \"qs\";\n\nconst qsUtils = createQsUtils({\n  qs: {\n    parse: (search) =\u003e parse(search, { ignoreQueryPrefix: true }),\n    stringify: (values) =\u003e stringify(values),\n  },\n});\n```\n\n## License\n\n[MIT](./LICENSE)\n\nCopyright (c) 2025 ViPro \u003cvdustr@gmail.com\u003e (\u003chttp://vdustr.dev\u003e)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvdustr%2Fnanostores-qs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvdustr%2Fnanostores-qs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvdustr%2Fnanostores-qs/lists"}