{"id":25936888,"url":"https://github.com/mathisburger/search-param-transactions","last_synced_at":"2026-02-13T23:31:34.315Z","repository":{"id":280204396,"uuid":"941287016","full_name":"MathisBurger/search-param-transactions","owner":"MathisBurger","description":"Transaction management for search params in react-router-dom","archived":false,"fork":false,"pushed_at":"2025-03-02T00:00:57.000Z","size":22,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-16T05:43:10.537Z","etag":null,"topics":["react-router-dom","transaction-management","transactions","usesearchparams-hook"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/search-param-transactions","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/MathisBurger.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-01T23:29:52.000Z","updated_at":"2025-03-08T18:39:17.000Z","dependencies_parsed_at":"2025-03-02T00:24:22.851Z","dependency_job_id":"97b498cb-f491-42b2-beab-5bc34d11f9b6","html_url":"https://github.com/MathisBurger/search-param-transactions","commit_stats":null,"previous_names":["mathisburger/search-param-transactions"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/MathisBurger/search-param-transactions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathisBurger%2Fsearch-param-transactions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathisBurger%2Fsearch-param-transactions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathisBurger%2Fsearch-param-transactions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathisBurger%2Fsearch-param-transactions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MathisBurger","download_url":"https://codeload.github.com/MathisBurger/search-param-transactions/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathisBurger%2Fsearch-param-transactions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29423534,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T22:20:51.549Z","status":"ssl_error","status_checked_at":"2026-02-13T22:20:49.838Z","response_time":78,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["react-router-dom","transaction-management","transactions","usesearchparams-hook"],"created_at":"2025-03-04T02:54:59.086Z","updated_at":"2026-02-13T23:31:34.291Z","avatar_url":"https://github.com/MathisBurger.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React router search param transactions\n\nThere is one big problem with React Routers `useSearchParams` hook. The hook does not allow multiple updates in a row without overwriting the made updates to other search params. \nIf you have a setup with multiple hooks each for one search param and they all use the `useSearchParams` hook, you might run into this problem.\nThis problem is tackled by this library. \n\nThe approach of this library is to implement transactions for search params. To you can use our internal hook for mutable search params and just use it without transactions, but if you need them, you can use them!\n\n\n## Setup\n\nFirst you will need to download the library by using \n```bash\nnpm i search-param-transactions\n```\n\nThen you need to add our transaction wrapper at the top of your application (e.g. app.tsx or main.tsx)\n\n```tsx\nimport SearchParamTransactionWrapper from \"search-param-transactions\";\n\n\u003cSearchParamTransactionWrapper\u003e\n    Your children go here\n\u003c/SearchParamTransactionWrapper\u003e\n```\n\n\n## Usage\n\nAfter the initial setup you can now go on using it.\n\nThere are two ways of using transactional search params:\n\n### 1. `useMutableSearchParam` Hook\n\nThis hook provides the functionality of creating a getter and setter for a specific search param\n\n```tsx\nconst [getter, setter] = useMutableSearchParam('searchParamName');\nconsole.log(getter); // null\nsetter('foo');\nconsole.log(getter); // \"foo\"\n```\n**NOTE:** This code does not use transactional behaviour yet. The update is executed immediately.\n\nFor transactional behaviour you will need to use this:\n\n```tsx\nconst [getter, setter] = useMutableSearchParam('searchParamName');\nconst [getter2, setter2] = useMutableSearchParam('searchParamName2');\nsetter('foo', {noCommit: true}); // Data not commited yet\nsetter('bar'); // Commit happens here\n```\n\n### 2. `useTransactionalSearchParams` hook\n\nFor some more complex use cases where you need to go onto a lower level of abstraction, this hook might be the best way to go with.\n\n```tsx\nconst [searchParams, updateParam, commit] = useTransactionalSearchParams();\n```\n\n`searchParams` is the search params object as a total that can be used like the object of the normal useSearchParams hook.\n\n`updateParam` is a function that can be invoked to update a single search param. The change is not commited.\n\n`commit` is a function that can be invoked to flush all updates made by the `updateParam` function.\n\n\n## Further development\n\nThis library will be updated in the future if there are any wishes from the community. I am relatively active on GitHub. So just create an issue or a pull request and I will soon start working on it. \n\n\n## License\n\nThis application is MIT licensed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathisburger%2Fsearch-param-transactions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathisburger%2Fsearch-param-transactions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathisburger%2Fsearch-param-transactions/lists"}