{"id":15649626,"url":"https://github.com/katt/next-router-query","last_synced_at":"2025-04-30T16:29:27.322Z","repository":{"id":43305649,"uuid":"419881955","full_name":"KATT/next-router-query","owner":"KATT","description":"👨‍🔧 Drop-in alternative of `useRouter().query` that tries it's best to get the query params on the first mount.","archived":false,"fork":false,"pushed_at":"2021-10-21T22:43:13.000Z","size":299,"stargazers_count":39,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-30T17:51:12.665Z","etag":null,"topics":["nextjs","query","router","search"],"latest_commit_sha":null,"homepage":"https://next-router-query.katt.dev/","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/KATT.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"KATT"}},"created_at":"2021-10-21T21:29:25.000Z","updated_at":"2025-02-24T16:08:07.000Z","dependencies_parsed_at":"2022-09-01T11:51:27.543Z","dependency_job_id":null,"html_url":"https://github.com/KATT/next-router-query","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KATT%2Fnext-router-query","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KATT%2Fnext-router-query/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KATT%2Fnext-router-query/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KATT%2Fnext-router-query/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KATT","download_url":"https://codeload.github.com/KATT/next-router-query/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251742067,"owners_count":21636377,"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":["nextjs","query","router","search"],"created_at":"2024-10-03T12:30:33.712Z","updated_at":"2025-04-30T16:29:26.917Z","avatar_url":"https://github.com/KATT.png","language":"TypeScript","funding_links":["https://github.com/sponsors/KATT"],"categories":[],"sub_categories":[],"readme":"# `next-router-query`\n\n**Drop-in alternative of `useRouter().query` that tries it's best to get the query params on the first mount.**\n\n\n\u003e Have you ever gotten annoyed by the fact that `useRouter().query` is an empty object on the first mount? Great, then this is a library for you.\n\n## Illustrating the difference\n\nGiven a page called `post/[id].jsx` that is called with `/post/myId?key=value`:\n\nYou will see something like this when first mounting the page:\n\n```js\nuseRouter().query // result: {} // 😢 \n```\n\nWith `next-router-query` you'll see the difference\n\n\n```jsx\n--------- Render #1  --------\nuseRouter().query result: {} // 😢 \nuseRouterQuery() result: {id: 'myId', key: 'value'} // 😻\n```\n\nOnce the first render is done and `useRouter().query` returns data, we'll simply return that instead.\n\n## Caveats\n\n- This is an evening hack and is not production ready\n- Might cause hydration errors when using SSR\n- Relies on `URLSearchParams` - you might need some polyfill\n- Only works in the browser - server will not show the right result\n\n## Install\n\n```bash\nyarn add next-router-query\n# or \nnpm i next-router-query\n```\n\n### Usage\n\n```tsx\nimport { useRouterQuery } from 'next-router-query';\n\nexport function MyPage() {\n  const routerQuery = useRouterQuery()\n\n  // ...\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkatt%2Fnext-router-query","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkatt%2Fnext-router-query","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkatt%2Fnext-router-query/lists"}