{"id":23516360,"url":"https://github.com/varanauskas/nexered","last_synced_at":"2025-04-19T16:27:26.960Z","repository":{"id":57687762,"uuid":"481715421","full_name":"varanauskas/nexered","owner":"varanauskas","description":"Support Next.js redirects in Cloudflare Pages","archived":false,"fork":false,"pushed_at":"2022-11-27T22:22:56.000Z","size":42,"stargazers_count":17,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T01:47:09.206Z","etag":null,"topics":["cloudflare","cloudflare-pages","next","nextjs","redirect","redirects","seo","seo-optimization","static-export","static-site-generator"],"latest_commit_sha":null,"homepage":"","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/varanauskas.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}},"created_at":"2022-04-14T18:49:57.000Z","updated_at":"2024-12-08T04:40:52.000Z","dependencies_parsed_at":"2023-01-22T02:04:23.756Z","dependency_job_id":null,"html_url":"https://github.com/varanauskas/nexered","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varanauskas%2Fnexered","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varanauskas%2Fnexered/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varanauskas%2Fnexered/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varanauskas%2Fnexered/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/varanauskas","download_url":"https://codeload.github.com/varanauskas/nexered/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249738273,"owners_count":21318501,"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":["cloudflare","cloudflare-pages","next","nextjs","redirect","redirects","seo","seo-optimization","static-export","static-site-generator"],"created_at":"2024-12-25T15:13:06.026Z","updated_at":"2025-04-19T16:27:26.929Z","avatar_url":"https://github.com/varanauskas.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NEXERED\n\nSupport Next.js redirects in your hosting provider\n\n---\n\n[Next.js redirects](https://nextjs.org/docs/api-reference/next.config.js/redirects)\ndefined in `next.config.js` do not work in static HTML exports.\n\nHowever, in many hosting providers (for example Cloudflare Pages) it is possible\nto define a static redirect config (for example `_redirects` file).\n\nThis package aims to parse existing `next.config.js` and automatically define\nconfiguration for those third party hosting providers.\n\n## Get started\n\n1. Install `nexered` using your package manager\n    ```sh\n    yarn add nexered\n    ```\n    or if you're using `npm`\n    ```sh\n    npm install nexered\n    ```\n\n2. Add `nexered` to the `postbuild` [(or the `post-` script of the static export script if it's named differently)](https://docs.npmjs.com/cli/v6/using-npm/scripts#pre--post-scripts) step in `package.json`\n    ```diff\n    {\n        \"scripts\": {\n            \"postbuild\": \"nexered --provider=cloudflare-pages\"\n        }\n    }\n    ```\n\n3. ...\n\n4. Profit\n\n## Supported providers\n\n- [Cloudflare Pages](https://developers.cloudflare.com/pages/platform/redirects/)\n\n    Supports `:wildcards*` and `:slugs` and same status codes as next.js\n    \n    Example:\n    ```js\n    // next.config.js\n    /**\n     * @type {import('next').NextConfig}\n     */\n    const nextConfig = {\n        basePath: \"/base-path\",\n        async redirects() {\n            return [\n                {\n                    source: '/old-page',\n                    destination: '/new-page',\n                    permanent: true,\n                },\n                {\n                    source: '/old-wildcard/:path*',\n                    destination: '/new-wildcard/:path*',\n                    permanent: false\n                },\n                {\n                    source: '/old-blog/:slug',\n                    destination: '/new-blog/:slug',\n                    permanent: true,\n                },\n                {\n                    source: '/without-base-path',\n                    destination: '/absolute-path',\n                    basePath: false,\n                    permanent: false,\n                },\n                {\n                    source: '/custom-status-code',\n                    destination: '/status-code-303',\n                    statusCode: 303\n                }\n            ];\n        },\n    };\n\n    module.exports = nextConfig;\n    ```\n\n    ```\n    // out/_redirects\n    /base-path/old-page /base-path/new-page 308\n    /base-path/old-wildcard/* /base-path/new-wildcard/:splat 307\n    /base-path/old-blog/:slug /base-path/new-blog/:slug 308\n    /without-base-path /absolute-path 307\n    /base-path/custom-status-code /base-path/status-code-303 303\n    ```\n\n## Usage\n```\nnexered --p=cloudflare-pages\n\nOptions:\n      --help      Show help                                            [boolean]\n      --version   Show version number                                  [boolean]\n  -p, --provider  hosting provider type [required] [choices: \"cloudflare-pages\"]\n  -o              `next export` output directory as described in\n                  https://nextjs.org/docs/api-reference/next.config.js/exportPat\n                  hMap#customizing-the-output-directory[string] [default: \"out\"]\n      --dir       next project directory containing `next.config.js`\n                                                         [string] [default: \".\"]\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaranauskas%2Fnexered","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvaranauskas%2Fnexered","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaranauskas%2Fnexered/lists"}