{"id":14957472,"url":"https://github.com/bamdadfr/next-replace-url","last_synced_at":"2025-05-02T07:33:04.902Z","repository":{"id":37893491,"uuid":"475959080","full_name":"bamdadfr/next-replace-url","owner":"bamdadfr","description":"Replace URL parameters in Next.js without re-rendering.","archived":false,"fork":false,"pushed_at":"2024-07-03T00:13:14.000Z","size":186,"stargazers_count":9,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-29T23:08:13.757Z","etag":null,"topics":["nextjs","replace","router","url"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/next-replace-url","language":"JavaScript","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/bamdadfr.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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},"funding":{"github":"bamdadsabbagh","patreon":null,"open_collective":null,"ko_fi":"bamdadsabbagh","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2022-03-30T16:18:03.000Z","updated_at":"2024-10-17T18:23:54.000Z","dependencies_parsed_at":"2024-07-06T09:22:36.920Z","dependency_job_id":null,"html_url":"https://github.com/bamdadfr/next-replace-url","commit_stats":null,"previous_names":["bamdadfr/next-replace-url","bamdadsabbagh/next-replace-url"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamdadfr%2Fnext-replace-url","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamdadfr%2Fnext-replace-url/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamdadfr%2Fnext-replace-url/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamdadfr%2Fnext-replace-url/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bamdadfr","download_url":"https://codeload.github.com/bamdadfr/next-replace-url/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224305847,"owners_count":17289446,"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","replace","router","url"],"created_at":"2024-09-24T13:14:57.066Z","updated_at":"2024-11-12T16:04:52.643Z","avatar_url":"https://github.com/bamdadfr.png","language":"JavaScript","readme":"![release](https://img.shields.io/github/v/release/bamdadfr/next-replace-url)\n![license](https://img.shields.io/github/license/bamdadfr/next-replace-url)\n\nReplace URL parameters in Next.js without re-rendering.\n\n## 🚀 Getting Started\n\n```bash\nnpm install next-replace-url\nyarn add next-replace-url\n```\n\n```javascript\nimport {useNextReplaceUrl, nextReplaceUrl} from 'next-replace-url';\n\n// in your functional component\nuseNextReplaceUrl('parameter', value);\n\n// from anywhere\nnextReplaceUrl('parameter', value);\n```\n\n## 📖️ Description\n\nThe module replaces the `window.history.state` object therefore bypassing Next.js routing context, avoiding re-renders.\n\nSome suggest shallow routing which unfortunately does not prevent re-renders.\n\n### Under the hood example\n\n```javascript\n// User navigates to https://example.com/audio/1\n\n// Current state\nwindow.history.state = {\n  \"url\": \"/audio/[volume]?volume=1\", // Next.js URL\n  \"as\": \"/audio/1\" // What user sees\n}\n\n// Running the following command will replace the URL parameter \"volume\" with \"2\"\nnextReplaceUrl('volume', '2')\n\n// Resulting state\nwindow.history.state = {\n  \"url\": \"/audio/[volume]?volume=2\",\n  \"as\": \"/audio/2\"\n}\n```\n\n## 📖️ Related discussions\n\n- https://github.com/vercel/next.js/discussions/18072\n","funding_links":["https://github.com/sponsors/bamdadsabbagh","https://ko-fi.com/bamdadsabbagh"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbamdadfr%2Fnext-replace-url","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbamdadfr%2Fnext-replace-url","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbamdadfr%2Fnext-replace-url/lists"}