top | item 41858990

(no title)

hijodelsol | 1 year ago

I truly feel like the focus on PPR, streaming, etc. is forcing most developers to jump through unnecessary hoops and relearn the basics of Next.js every couple of months. Imo, the interceptors idea is just more evidence for that. On the surface, Next.js may try to keep all parts independent and allow PPR, streaming, static and dynamic living right next to each other, etc. but at what cost? Losing the request and the response object makes life unnecessarily harder. Artificially limiting certain pages to run in an "edge environment" is non-sensical when hosting Next.js on Node.js in the same data center as your database. And personally, I do not trust Next.js anymore with new "special" files and features. head.tsx was deprecated before our migration was even complete. Route interception with parallel routes is deeply broken to this day with hundreds of non-obvious caveats of how they can be used. Server actions are an anti-pattern, since they tie all manipulations to Next.js and make it impossible to use your data manipulation endpoints across multiple applications. Meanwhile, using REST-APIs with Next.js is incredibly challenging thanks to the client side cache and is not fully solved by router.refresh, tag invalidation or stale time.

I believe that there are many like me who would just want to use a simple server-side rendering solution with the route-based layout structure of the app directory, which was a great improvement. Please just allow users to render everything at once and synchroneously in Next.js, expose the request and response at every point and allow database access from any point. I would be very happy to trade 2ms of time and lose PPR, etc. if that meant that I could build features for my customers faster. The introduction of the app directory had me exited and I moved the first project on the day it was announced, but recently I find myself fighting the framework rather than it supporting what I need to do.

Another example of Next.js completely breaking existing code seemingly for no reason was suddenly disallowing exporting functions from page.tsx files. It worked before, so there should not be any inherent reason that it could not work anymore. Now, if I want to reuse a getData method in two pages or a page and a layout, I have to create an additional getData.ts file. Is this was the Next.js team wants users to do? Perhaps. Should they force them to do this? Absolutely not, we are all adults and requiring millions of devs to refactor their code because something could not be figured out internally or they suddenly deemed some usage unacceptable is ridiculous and user hostile.

discuss

order

No comments yet.