{"id":13998528,"url":"https://github.com/nitedani/zustand-querystring","last_synced_at":"2025-04-12T00:16:03.727Z","repository":{"id":64131631,"uuid":"573610162","full_name":"nitedani/zustand-querystring","owner":"nitedani","description":"A Zustand middleware that syncs the store with the querystring.","archived":false,"fork":false,"pushed_at":"2025-02-28T22:10:18.000Z","size":350,"stargazers_count":63,"open_issues_count":5,"forks_count":9,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-12T00:15:57.699Z","etag":null,"topics":["querystring","state","state-management","zustand"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nitedani.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2022-12-02T22:17:50.000Z","updated_at":"2025-03-28T07:12:00.000Z","dependencies_parsed_at":"2024-06-10T16:27:29.971Z","dependency_job_id":"52ee499b-eaf5-4bbf-a47f-3fa5eaed9380","html_url":"https://github.com/nitedani/zustand-querystring","commit_stats":{"total_commits":36,"total_committers":1,"mean_commits":36.0,"dds":0.0,"last_synced_commit":"1ab34ce60c5f62f3b6f7c5a2ca22463853b20011"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitedani%2Fzustand-querystring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitedani%2Fzustand-querystring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitedani%2Fzustand-querystring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitedani%2Fzustand-querystring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nitedani","download_url":"https://codeload.github.com/nitedani/zustand-querystring/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248497818,"owners_count":21113984,"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":["querystring","state","state-management","zustand"],"created_at":"2024-08-09T19:01:45.198Z","updated_at":"2025-04-12T00:16:03.703Z","avatar_url":"https://github.com/nitedani.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# zustand-querystring\n\nA Zustand middleware that syncs the store with the querystring.\n\nTry on [StackBlitz](https://stackblitz.com/github/nitedani/zustand-querystring/tree/main/examples/react) (You need to click \"Open in New Tab\")\n\nExamples:\n\n- [React](./examples/react/)\n- [NextJS](./examples/next/)\n- [Rakkas](./examples/rakkas/)\n\nQuickstart:\n\n```ts\nimport create from \"zustand\";\nimport { querystring } from \"zustand-querystring\";\n\ninterface Store {\n  count: number;\n  ticks: number;\n  someNestedState: {\n    nestedCount: number;\n    hello: string;\n  };\n}\n\nexport const useStore = create\u003cStore\u003e()(\n  querystring(\n    (set, get) =\u003e ({\n      count: 0,\n      ticks: 0,\n      someNestedState: {\n        nestedCount: 0,\n        hello: \"Hello\",\n      },\n    }),\n    {\n      // select controls what part of the state is synced with the query string\n      // pathname is the current route (e.g. /about or /)\n      select(pathname) {\n        return {\n          count: true,\n          // ticks: false, \u003c- false by default\n\n          someNestedState: {\n            nestedCount: true,\n            hello: \"/about\" === pathname,\n          },\n\n          // OR select the whole nested state\n          // someNestedState: true\n        };\n      },\n    },\n  ),\n);\n```\n\nquerystring options:\n\n- \u003cb\u003eselect\u003c/b\u003e - the select option controls what part of the state is synced with the query string\n- \u003cb\u003ekey: string\u003c/b\u003e - the key option controls how the state is stored in the querystring (default: $)\n- \u003cb\u003eurl\u003c/b\u003e - the url option is used to provide the request url on the server side render\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnitedani%2Fzustand-querystring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnitedani%2Fzustand-querystring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnitedani%2Fzustand-querystring/lists"}