1.1.3 • Published 1 year ago

nextjs-to-netlify-redirect-exporter v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

This package has moved

This package has been moved to next-redirect-generator.


What is this?

Tool to generate netlify.toml redirects from Next.js dynamic routes in the pages folder.

Use case

If you are doing a next export but you have one or more dynamic routes (eg /pages/[yourVariable].jsx) you will end up with files like [yourVariable].html inside your out folder. Going to this page directly will result in a 404. To deal with this problem we need to set up Netlify redirects which look like:

[[redirects]]
from = "/:yourVariable
to = "/[yourVariable].html"
status = 200

This tool will autogenerate those and spit them out in the console for you to copy into your Netlify.toml file - for convenience and to eliminate human error.

How to run

Execute using NPX: npx nextjs-to-netlify-redirect-exporter

or

Install yarn add -D nextjs-to-netlify-redirect-exporter & yarn run nextjs-to-netlify-redirect-exporter

Run the command in the root of your Next.js project - the script looks for a pages folder in your current working directory.

Examples

  1. _redirects file format (stick in your public folder).

yarn run nextjs-to-netlify-redirect-exporter --format="_redirect"

  1. Netlify.toml file format.

yarn run nextjs-to-netlify-redirect-exporter --format="netlify.toml"

  1. Alternate pages directory.

yarn run nextjs-to-netlify-redirect-exporter --path="src/pages" else it will look at the closes pages folder in your CWD.

Important

Run this at your repo root.

1.1.3

1 year ago

1.1.2

1 year ago

2.0.7

1 year ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.16

2 years ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.5

1 year ago

2.0.4

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.12

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago