I'm asking this is because I want to go back to MVC, but I don't want to miss out on the nice libraries out there built for React. Hence I want to combine MVC + React as a library.
Ask HN: How do you use React as a library in 2024?
1–4 of 4 posts
Re: Ask HN: How do you use React as a library in 2024?
#2- What do you mean by "React as a library"? Using it as a pure SPA with a bundler like Vite? Using it as a plain `` tag?
- What do you mean by "go back to MVC"? What does "MVC" mean specifically in this case?
Re: Ask HN: How do you use React as a library in 2024?
#3Can you clarify some terms here? - What do you mean by "React as a library"? Using it as a pure SPA with a bundler like Vite? Using it as a plain ` ` tag? - What do you mean by "go back to MVC"? What does "MVC" mean specifically in this case?
Yes.
- What do you mean by "go back to MVC"? What does "MVC" mean specifically in this case?
MVC as in Model-View-Controller.
To give more context, I'm prototyping a lot, and having to create endpoints for every single APIs is quite a chore. Also I want to avoid the overhead of having to run separate server just to host the frontend (e.g. NextJS)
Re: Ask HN: How do you use React as a library in 2024?
#4Can you clarify some terms here? - What do you mean by "React as a library"? Using it as a pure SPA with a bundler like Vite? Using it as a plain ` ` tag? - What do you mean by "go back to MVC"? What does "MVC" mean specifically in this case?
- Using it as a plain ` ` tag? Yes. - What do you mean by "go back to MVC"? What does "MVC" mean specifically in this case? MVC as in Model-View-Controller. To give more context, I'm prototyping a lot, and having to create endpoints for every single APIs is quite a chore. Also I want to avoid the overhead of having to run separate server just to host the frontend (e.g. NextJS)
Normally "MVC" as a concept doesn't get used in the React ecosystem (the way it did with Backbone.js).
FWIW it's certainly _possible_ to use React as a script tag, but it's extremely rare. It's normally expected that the frontend _is_ actually bundled and compiled, whether it be using a pure-SPA build tool like Vite, or one of the full server-side frameworks like Next or Remix.
Note that the SPA build output is just a set of static HTML/JS/CSS files, which do not require a separate Node server process for hosting - they can be served by any HTTP server.
My own advice would be to use Vite and build as an SPA.
_If_ you absolutely want to use React as _just_ a `` tag with no build step, I'd recommend also using https://github.com/developit/htm to at least give you JSX-like syntax for writing your components.