Hacker News new | ask | show | jobs
by wmfiv 1426 days ago
I'm struggling with the idea that React is a primitive used to build a Web Framework.
6 comments

It's because almost no one uses React the way it was created, but ultimately depends on what you mean by Web Framework. I don't think react includes enough to be a web framework.

It's a library to make components for web pages. Notably, Facebook's chat window. Later, one people decides that it's a good idea to have one giant component mounted at `body` or `div` directly underneath the body that would hold everything else and even the sun.

React didn't have much for state management and doesn't have anything for navigation support. It was released in 2013 and Create React App, which is actually a framework, was released only in 2016. Even that isn't a framework, but rather a template.

Now, Next.js and Gatsby are actually frameworks based on React. Backbone.js is an MVC framework.

I think the problem is that react is larger than several frameworks but provide 1/10 of the functionality.

If react were preact it would feel smaller and people who care about performance would embed it without thinking too much

I have seen it said as "React is neither a library nor a web framework, but a view framework"
I'm not a fan of React myself, but it's just a view layer. Or at least that's all it was when I last looked into it a few years back.
You could swap out React here for another solution (e.g Svelte) and it would mostly read the same. The Build Output API[1] mentioned is how React, Vue, Svelte, and their "metaframeworks" run on Vercel today.

[1]: https://vercel.com/blog/build-output-api

React can be used as a templating library server-side in a node environment (like handlebars). It's a bit heavy for the task but it works.
A huge benefit React (and anything else that uses JSX) has over text-based templating is that you can strictly lint/typecheck JSX because ultimately it's just syntactic sugar over plain JS.
You can typecheck anything there exists a typechecker for.

Vue templates are typechecked for example.

React is "just" a library, it doesn't give you everything you need to build out a full-stack or framework.

For example, see Clojure's Luminus: https://luminusweb.com/

You have to dig down deep to find where React is.

I think it’s easier to consider when you look at the frameworks that provide React + some other features. Of course you could swap React with something else, or write your own rendering + state management.

I think it’s similar to how Java web servers often use the library Netty under the hood. Why re-solve a problem?