Re:New React docs pretend SPAs don't exist anymore
by jameshart on Friday March 17, 2023 @07:21PM
(#35204194)
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(<MyApp/>) 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
by leerob on Friday March 17, 2023 @07:42PM
(#35204404)
If you roll your own with a bundler, you will also need to integrate a router. Next.js is providing a routing layer for you. If you want to stick with a static/SPA the entire time, that's fine. You don't have to use SSR unless you need it.
https://nextjs.org/docs/advanced-features/static-html-export
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 until now is that they add a lot of parts I don't need, and the documentation seems to be focused on the SSR part. And then there are React server side components, which is another new concept I need to understand. Maybe the frameworks are a good fit for my SPA use cases, but it'll take quite a bit of time to find out if that is true.