{"id":15489575,"url":"https://github.com/pablopunk/nextjs-redirect-locale","last_synced_at":"2025-04-22T18:24:04.907Z","repository":{"id":74867501,"uuid":"258540672","full_name":"pablopunk/nextjs-redirect-locale","owner":"pablopunk","description":"Redirect to corresponding locale route","archived":false,"fork":false,"pushed_at":"2020-11-08T13:52:06.000Z","size":21,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T17:35:55.532Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pablopunk.com","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/pablopunk.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":"2020-04-24T14:49:36.000Z","updated_at":"2022-05-13T15:10:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"84620c2e-4cfd-4ff8-b270-8121caffbd3a","html_url":"https://github.com/pablopunk/nextjs-redirect-locale","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pablopunk%2Fnextjs-redirect-locale","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pablopunk%2Fnextjs-redirect-locale/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pablopunk%2Fnextjs-redirect-locale/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pablopunk%2Fnextjs-redirect-locale/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pablopunk","download_url":"https://codeload.github.com/pablopunk/nextjs-redirect-locale/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249626611,"owners_count":21302228,"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":[],"created_at":"2024-10-02T07:06:29.547Z","updated_at":"2025-04-22T18:24:04.899Z","avatar_url":"https://github.com/pablopunk.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nextjs-redirect-locale\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/pablopunk/miny\"\u003e\u003cimg src=\"https://img.shields.io/badge/made_with-miny-1eced8.svg\" /\u003e \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/nextjs-redirect-locale\"\u003e\u003cimg src=\"https://img.shields.io/npm/dt/nextjs-redirect-locale.svg?color=6c5ce7\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://packagephobia.now.sh/result?p=nextjs-redirect-locale\"\u003e\u003cimg src=\"https://packagephobia.now.sh/badge?p=nextjs-redirect-locale\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ci\u003eRedirect to corresponding locale. Works on client and server.\u003c/i\u003e\n\u003c/p\u003e\n\n\u003e Note: This project still works but there's now an official way of doing i18n in NextJS. [Check out the official docs](https://nextjs.org/docs/advanced-features/i18n-routing).\n\n## Install\n\n```sh\nnpm install nextjs-redirect-locale\n```\n\n## Usage\n\nLet's say you have a next.js project ([like this one](https://github.com/pablopunk/pablopunk.com)) that creates one route per locale automatically, i.e. a page like `page/home.js` will be available in different languages with the following routes:\n\n- `/en/home`\n- `/es/home`\n- `/gl/home`\n- `/fr/home`\n- `/fr_CA/home`\n\nIf you want to redirect to the proper locale once the user visits `/`, then you can create a `pages/index.js` with the following code:\n\n```jsx\nimport redirectLocale from 'nextjs-redirect-locale'\nexport default redirectLocale(['en', 'es', 'gl', 'fr', 'fr_CA'])\n```\n\nResult: `/` redirects to `/es/` (if user locale is `es`)\n\nKeep in mind the first locale is gonna be the default (i.e. the one that gets selected if the user locale is not on the list).\n\nYou can checkout this example live in [pablopunk.com](https://pablopunk.com/).\n\nAlso, here's a demo of the code you can play with: [codesandbox.io/s/nextjs-redirect-locale-ci](https://codesandbox.io/s/nextjs-redirect-locale-ci-utjwg).\n\n## Static export\n\nThis package is compatible with static exports via `next export` since version 2.0.0\n\n## Related\n\n- Custom redirects for NextJS: [nextjs-redirect](https://github.com/pablopunk/nextjs-redirect)\n\n## License\n\nMIT\n\n## Author\n\n| ![me](https://gravatar.com/avatar/fa50aeff0ddd6e63273a068b04353d9d?size=100) |\n| ---------------------------------------------------------------------------- |\n| [Pablo Varela](https://pablo.pìnk)                                           |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpablopunk%2Fnextjs-redirect-locale","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpablopunk%2Fnextjs-redirect-locale","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpablopunk%2Fnextjs-redirect-locale/lists"}