Live data from Hacker News

React Router 6

reactrouter.com

41–49 of 49 posts

Re: React Router 6

#41
post #4

I think we're at an interesting time for React routing. It seems like a ton of shops are standardizing on Next.js as a base for new projects, especially if you're building a pretty vanilla web app. Since Next takes care of routing for you, the need for projects like this operating at huge scales is diminishing. I'm glad they still exist for teams that want/need to own the entire application stack, but there are benef…

I'm not sure about that, Next.js' routing is very limited compared to React Router, so much so that I actually spent some time evaluating whether it was worth introducing react-router and skipping Next's half-arsed implementation of a router in a project at work. I've been very vocal against Next multiple times recently, so I'm definitely biased, but I wouldn't use it for anything more than a basically static web app…

> Next.js' routing is very limited compared to React Router

What specifically do you find is lacking?

> I've been very vocal against Next multiple times recently, so I'm definitely biased, but I wouldn't use it for anything more than a basically static web app. Its whole API is very basic, and quite shallow and underdocumented when you need to go a little deeper than "compile this React component into a static html page" and filesystem-based routing.

Could you be more specific? Next.js was originally designed for server-rendered React apps, so I'm wondering how you landed to using it only for static web apps.

Especially would love to hear more about what you think is missing from the docs.

Re: React Router 6

#42
post #26

Earlier quoted context omitted.

I'm curious: what specific problems are you running into?

Nested routing. It's basically unusable for a master/detail view, which is common in dashboard apps.

Have you seen this? https://nextjs.org/docs/basic-features/layouts

Re: React Router 6

#43
I really don't think react-router provides enough functionality to justify the amount of churn it's generating. URL routing is not complicated and not hard. After getting dragged through a v3->v4 upgrade by a library we use, I put in a lint rule forcing all usages of it to go through a wrapper.

Re: React Router 6

#44
post #39

Earlier quoted context omitted.

Wow, another library (react-location) that shows TypeScript as its primary documentation language. And I see more and more jobs hiring for TypeScript developers. I see Microsoft's 3 E's campaign strongly in action with TypeScript. For those who care about Corporate Ethics, please review Microsoft's: https://en.wikipedia.org/wiki/Embrace,_extend,_and_extinguis... For that reason, I refuse to touch TypeScript libraries…

Well, it's open source and they aren't going to extinguish JavaScript anytime soon. So I don't see how it would apply here.

Microsoft are actively hostile towards JavaScript now. I have been monitoring the progress of vscode's support for JavaScript and noticed that it now clearly a second class citizen. The TypeScript compiler now declares valid and working JavaScript as having errors, and these are displayed to the user in vscode. One example is the usePrevious hook as mentioned on the react website. If you mouse over its signature in vscode, you will see it is undefined -> undefined. This is because useRef() has no argument, and the generic type is inferred from this argument, and JavaScript has no way to do useRef();

Re: React Router 6

#46
post #17

I am I the only who finds this library a wee bit overengineered?

what part is over-engineered?

All of it.

Think of it this way. How would you do routing in a React app from scratch:

1. Listen for changes in the URL.

2. Parse the new URL into a routing object.

3. Pass the routing object down through the component hierarchy.

You can do that in maybe 5-10 lines of straightforward code.

Re: React Router 6

#47

The author of react-query (one of my favorite libraries) also just released the beta of yet another router called React Location: https://react-location.tanstack.com/ I've used Reach Router in the past and it's also pretty nice, but I didn't see a reason to use it over React Router... https://reach.tech/router/

Wow, another library (react-location) that shows TypeScript as its primary documentation language. And I see more and more jobs hiring for TypeScript developers. I see Microsoft's 3 E's campaign strongly in action with TypeScript. For those who care about Corporate Ethics, please review Microsoft's: https://en.wikipedia.org/wiki/Embrace,_extend,_and_extinguis... For that reason, I refuse to touch TypeScript libraries…

If you're going to about Microsoft's ethics, it's probably also necessary to complain about Facebook's ethics since they own React.

Re: React Router 6

#48

The author of react-query (one of my favorite libraries) also just released the beta of yet another router called React Location: https://react-location.tanstack.com/ I've used Reach Router in the past and it's also pretty nice, but I didn't see a reason to use it over React Router... https://reach.tech/router/

Vue has an official router library, but react seems to have multiple popular routing libraries. Reinventing the wheel much?

I've definitely found it a little weird how React doesn't have a more official routing library, especially since they are all so similar.

It feels like Next.js is taking over a lot of things that React _should_ have by default but doesn't. Which is fine, but Next.js is also a little too much for a lot of smaller projects I work on.

Re: React Router 6

#49
post #40

Earlier quoted context omitted.

There are many reasons, but what I was saying is that if you don't use the routing, then a lot of the value of NextJS disappears.

Could you share the reasons you don't pick Next.js? Are you only finding value in the file system routing?

I do pick NextJS, and I like it - but what I’m saying is the file system routing is critical to other features like static props and SSR, so if you don’t use the file system routing and try to work around it by using react router on some catch all wildcard route, I think you are missing out on a lot of the architectural perks of NextJS. For instance even with new features like edge middlewares, once again its behavior is dependent on using the file system routing.

Personally I actually don’t really like the file system routing, much preferring how route structure is expressed in code with react router (I had set up a system in another project to never have any broken links since page routes were enumerated in a type that links were forced to refer to by TypeScript; I just can’t do that with file system based routing without duplicating and needing to sync paths), but I feel like I’m obligated to use it by the virtue of having chosen NextJS and wanting to make use of its optimization features, so I’m just tolerating that.

Also hi leerob :)

Post reply on HN