Hacker News new | ask | show | jobs
by aj0strow 1492 days ago
Oh interesting. Why not? Directory and file based routing is my favorite feature of Next.js, Remix, and other frameworks that do it.
2 comments

I don't like this approach either as maintenance gets complex over time. Changing routes in my React-router project is one file, one commit that's easy to verify, try changing a dozen routes with Next and you end up with a dozen of files moved around, with folder structure possibly impacted as well, I see this as an anti-pattern.
That's true, the pull request diff viewer does not make viewing file renaming very clear and there could be conflicts.

On the other hand, what I see in practice is adding or removing context providers and layout components in the react router file, it becomes huge, and all the diffs change all of the lines with new indentation.

It makes route localization a second-class citizen in the framework at best, or a totally unsupported hack-your-own-solution thing at worst.
It seems like a path prefix like "/en/books" or "/es/books" could be supported with a base url config.

Localized path segments like "/books" or "/libros" could be supported with a path segment mapping configuration.

It should work fine in theory. I guess those configs don't exist yet. Or is there something else that route localization requires?

if it helps, you could use middleware in next.js to handle routing to separate folders easier.
Middleware won't work if you use "next export" to get a truly static site though, which is by far my preferred mode of operation whenever possible.

This is what I meant when I said "second-class citizen at best".

ah I see. Maybe try the route rewriting in next.conf.js? I think thats what the file is. That might work for static sites.