30 points · by bripkens · 1y ago · 51 comments
You can just have a HTML file with an SPA that calls API. This is fine.
Pondering an SSR rendered SPA with a wildcard route that calls `React.renderToPipeableStream` (or even simpler, uses `react-streaming`) and some `import()` statements sprinkled about, dropped into a tiny vite config: OMG! a handful of lines of code. Such complexity! Such slow performance! and massive bundle sizes!
Capture the market, complexify everything, then overcharge for hosting. Thanks Vercel. Love your docs!
Uses the same code to render on server and in browser, enables moving render logic from browser to server and vice versa without doing a complete rewrite.
PHP is a programming language, Rails is a framework. They're quite different propositions. What you're seeing here is equivalent to poking around in the guts of Rails, which assuredly has plenty of complexity hidden inside it. I personally have a negative reaction to this amount of stuff in a project but I feel similarly about Rails.
Next’s big “thing” is one codebase that runs both on the server and client. That introduces complexity where you might not expect it. But a Rails app and a totally disconnected JS front end will also introduce complexity, just a kind you’re more familiar with.
it's an incredibly polished server and it does a lot of complex stuff to be so fast, but it's also well documented.
> Uses the same code to render on server and in browser, enables moving render logic from browser to server and vice versa without doing a complete rewrite.
However, the next question is, does it solve these without adding needless additional complexity of it's own?
I can't help but feel, while I'm using it, that surely it shouldn't feel this overengineered and unintuitive. I mean, I like React, and I understand it well, footguns and all.
I feel like there might be better solutions out there - even using React - and if it wasn't being heavily promoted by a large corporation then something else would be in it's place.
Also, how much of the functionality of Next.js (Image component processing, for example) is designed to funnel you into using Vercel rather than being genuinely the best solution?
in our case it solves performance, it actively keeps cache warmed up preventing it from ever serving a stale page or serving a non cached hit, preloads content for fast navigation, optimizes images, it's lightweight, scales horizontally, it's stable.
it has all the bells and whistles the big boys have, for free, you almost don't need to think about it, just follow some guidance.
while people say it's too much magic (there are 4 cache layers), you are always free to pop up the hood and read the documentation, which is excellent.
RSC is a cool feature, but I'm still not convinced that the added churn of thinking about "colours" when building components and structuring the component tree is worth it for the benefits it gives.
Add in tailwind and a router of choice (I love wouter) and you've got 90% of what you need to build most applications. Vite is so much simpler than webpack and the rest that came before, it's a tiny amount of work to do this.
The basic thing I instrumented in my projects was a count of calls to APIs and their total time. Same for DB access. Then push these out as server timings via http headers and see them in chrome.
Quick and dirty way to see what the server call was generally doing.
In addition to adding that to chrome dev tools, I had an extension that would consolidate all network requests for a given page and summarize them. Nice to show various teams how many darn db queries they were doing just to load a page.
Those days are gone. Scale your Next.js RSC app to anything larger than a toy or marketing site and get f'ing burned.
Are you using the pages router or the app router? If you're using the pages router you'll probably be fine.
When it works, it really is easy. But when it doesn’t work, it is absolutely infuriating. Too much magic going on, I guess.
A couple months ago, I was still under the impression that next.js is the easiest way to scaffold a simple site. I even tried hosting it on vercel for ultra-easy mode.
I got some inscrutable build errors that had like the thumbs-ups on an unresolved GitHub issue. So I tried running it from a VPS I already had, and it worked fine!
I would absolutely not use it again though. Vite is great, and if I need SSR at any point I’ll just hope that the tanstack SSR solution is 1.0 by then lol
I've noted a tendency to not log stuff in some js-first devs i know ... they all say 'i'll reproduce it locally'...
How much stuff do you log in the server? I’ve only ever seen devs log basic high-level stuff. But to actually debug something, you need way more information.
I’ve tried sticking debug-level logs that log all sorts of business logic. Pretty much recreating what you would do with console.log when trying to isolate an issue locally.
But then you have your code permanently littered with debug log lines! It makes things… ugly!!
If you NEED detailed logging, do you just deal with the uglified code? Or is there a better solution? Decorators that logs parameters and such automatically??
or is it best practice to patch with logs only without reproduction
But you are of course also right that you can just attach a debugger. That's also called out in the article.