Live data from Hacker News

New React docs pretend SPAs don't exist anymore

wasp-lang.dev

11–20 of 225 posts

Re: New React docs pretend SPAs don't exist anymore

#11
Starting a "new react project" should be basically creating an HTML file, and adding a script tag linking to React the JS library. Why are these developers always trying to obfuscate everything with tons and tons of layers of indirection all the time? You don't need to "bundle" anything and certainly not use some server just to add Javascript to a page (unless it's a matter of CSP of course) and you should certainly not have to rely on nodejs or cli tool X,Y,Z...

Somehow the JS/Node dev community managed to re-invent JEE web profile, and is very close to re-invent Glassfish as well at that point, but worse because it didn't learn anything from Java enterprise... this madness needs to stop.

Re: New React docs pretend SPAs don't exist anymore

#14
post #12

I just want to say, as a developer that just wants to get stuff done, I'm so annoyed by frameworks needing a meta framework, etc, etc. I want something as simple as CRA to be enough.

React is a library, not a framework, so you usually need something on top.

Re: New React docs pretend SPAs don't exist anymore

#15
post #9

As far as I understand you can use these frameworks to write SPAs as well. I have no idea how well supported that use case is in the end. I find the idea that you want to handle data fetching and routing in a framework to be reasonably convincing. There are advantages here, and it's easy to get into a bit of a mess if you just fetch data in each component. The part that has stopped me from looking at the frameworks u…

Basically if you do a static export from next.js and ignore routing, you get a react SPA.

You can do the same in Gatsby, but it's probably a waste of time.

But...

With an index.html file containing a createRoot(document.getElementById('root')).render() call, and parcel or vite or webpack, you can produce much the same thing.

Possible that next.js will give you easier access to some more interesting ways to split your JS bundle up - but also possible it will fight you if you continue to insist on not taking advantage of SSR.

Re: New React docs pretend SPAs don't exist anymore

#16
post #10

I don't think that's a fair characterization of the "Start a New React Project" page [0]. Next.js is the first option listed and is described as a way to "create React apps of any size—from a mostly static blog to a complex dynamic application." This reads to me like "Next.js can do SPAs (like CRA) plus static sites and SSR". Next.js' site even says "The core of Next.js has been designed to enable starting as a stati…

Your understanding is correct – Next.js can do static sites, SPAs, SSR – all of them.

We (just today) updated the Next.js docs linked based on feedback around this to make it more clear. Hopefully this helps, let me know if you have other feedback.

Re: New React docs pretend SPAs don't exist anymore

#17
post #10

I don't think that's a fair characterization of the "Start a New React Project" page [0]. Next.js is the first option listed and is described as a way to "create React apps of any size—from a mostly static blog to a complex dynamic application." This reads to me like "Next.js can do SPAs (like CRA) plus static sites and SSR". Next.js' site even says "The core of Next.js has been designed to enable starting as a stati…

"The core of Next.js has been designed to enable starting as a static site" is a little contradicted by the fact static export is considered an 'advanced feature' though.

That said, I'm not sure why running `next export` is considered 'advanced'.

Re: New React docs pretend SPAs don't exist anymore

#18
There are a myriad of reasons why I prefer SPA to server rendered content for most applications. The main exception is if I have a public facing, unauthenticated application that I need indexed, I'll go for SSR.

Off the top of my head, here are benefits to SPA:

- I can just serve a few static files from a CDN. Every user gets the same client.

- Most requests made by the application are actually smaller. I'm just loading the data I need, rather than the data, markup and styling.

- It's an actual client application talking to a data API. It's the same API the rest of my client applications are talking to, be it a mobile API, native, CLI, etc.

- It's a much easier mental model. Interactivity without having to give consideration to whether or not it will disrupt whether it can be rendered. I build my application like a realtime application and just make requests for the data I need when I need it

- I don't have to think about exposing backend secrets, or trying to do things I'm mistakenly assuming to necessarily run in one environment or the other

- I can be much more explicit about loading and caching data when I would like to

Even most of the cons of a SPA can be ameliorated. The biggest con is a larger up front load, but that can be mitigated by code splitting and lazy loading. The fact that it's a handful of static files means that the application is basically cached, too. And SPAs are for applications, not websites. Most people using SPAs want the application experience to be optimal, not necessarily their initial first time load. They want small requests, interactivity, live feedback. This is all possible with SSR, but nowhere near as simple.

Re: New React docs pretend SPAs don't exist anymore

#19
post #12

I just want to say, as a developer that just wants to get stuff done, I'm so annoyed by frameworks needing a meta framework, etc, etc. I want something as simple as CRA to be enough.

CRA has never been merely 'enough'. CRA started at 'too much' and started adding features from there.

Re: New React docs pretend SPAs don't exist anymore

#20

Starting a "new react project" should be basically creating an HTML file, and adding a script tag linking to React the JS library. Why are these developers always trying to obfuscate everything with tons and tons of layers of indirection all the time? You don't need to "bundle" anything and certainly not use some server just to add Javascript to a page (unless it's a matter of CSP of course) and you should certainly…

I honestly find this way more intuitive than JEE profiles.

It just makes sense when you take react as what it is: a library. Now, if you want amenities like a router you need to build it yourself or use something existing. 99.9% of people want this, so why not point them into the right direction?

Post reply on HN