Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The link you posted from Gaeron uses the (now deprecated) pages router, directly supporting my argument.

I did a migration from pages router to app router for my static-export project. Btw both are still present in v13, you can pick whichever you want, but long-term the pages router will be gone.

With static redirect/rewrites I mean the feature in pages router where you put in the "redirect"/"rewrite" statement in your next.config.js. These will be respected and work in a static export environment. If you try to perform a static export using app router, it will error and tell you that you have to remove "redirect"/"rewrite" from next.config.js and it is no longer supported.

Yes, you could use a middleware for redirects, but that is exactly my point: Middlewares do not work with static exports, they are middlewares for the server-side next server. Which is not present in a static export (and requires running your own server again, or use vercel's offering).

The same holds true for shallow routing for static exports, it is a feature still present in pages router, but not in app router. There is a GH issue of a lot of users complaining about this, but no feedback from the maintainers whether this is planned to bring back: https://github.com/vercel/next.js/discussions/48110



Indeed it uses pages router, my point was more the timing because it has been posted recently while Lee Rob was tweeting about next export being reenabled (in 13.4 I think).

For shalllow routing you are probably right (I don't use them much so I can't tell much, but I do have a few critics regarding app router too) but regarding rewrites, an URL rewrite has to happen in a server so I still don't get your point. What was removed in v13 is the shortcut via next.config.js not the ability to do rewrites/redirects which can be done easily using middlewares or whatever your host provides. It's also recommended to setup i18n yourself in a similar fashion instead of using the built-in config, something that I've been advocating for a long time (https://github.com/vercel/next.js/discussions/17631#discussi...).

Gaeron example or the comments below show how to handle dynamic routes rewrites via nginx for instance.


Rewrites and redirects do not need to be executed server-side ever since the html5 URL API. Of course you can redirect client-side, as in NextJS: router.push(). And given that redirects/rewrites work for the pages router also contradicts that point.

But yes, you will need to add support within the webserver like nginx. A simple modification to `try_files` will do, and is probably present in most deployments anyway (because you will want URL routes like example.com/news instead of example.com/news.html). I think they just not considered that feature in the design of the app router. And I also don't think it is technically impossible to apply client-side redirects/rewrites within app router.


>(now deprecated) pages router

The pages router is not deprecated. It will be supported for quite some time still, and is even receiving new features.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: