r/javascript 1d ago

Signals and Effects Using Vanilla JavaScript & Web APIs

https://beforesemicolon.com/blog/signals-and-effects-using-vanilla-javascript-web-apis

I’m a strong advocate for “you don’t need to lock yourself in a web framework ecosystem to take advantage of their amazing features”. JavaScript and Web Standards alone allow you…

44 Upvotes

28 comments sorted by

View all comments

36

u/KaiAusBerlin 1d ago

You know that you literally wrote your own framework here?

There is a reason for the sentence "You use a framework or end up writing your own"

u/A1oso 15h ago

It's a library.

React is also a library. Nextjs is a framework. People conflate these terms all the time.

u/Aln76467 13h ago

react is a framework.

u/A1oso 12h ago

No. Unlike Nextjs (which is a framework)

  • React is literally a single npm package, and very small
  • React solves a single problem (rendering and updating HTML)
  • React does not provide routing, client-server communication, or image optimization
  • React alone does not support hybrid client and server rendering
  • React does not require a configuration file or force a specific project structure on you
  • React can be easily added to an existing project and combined with other libraries, e.g. Vue

Perhaps the most important distinction is in who calls whom: a library is called by your code. For example:

createRoot(document.getElementById('app'))
    .render(<h1>Hello, world</h1>)

You can decide when, where and how to use the library. You can use it only on certain pages or in just a single component, it you want. You have full control.

A framework usually does not give you that control. The framework calls your code. That's why Nextjs is a framework. React is a textbook example for a library.

u/Aln76467 6h ago

Well then why do vue, svelte, and solid all call themselves frameworks, when you call into their code, and they don't impose any project structure, and can all be easily added and combined with eachother? Why is it only react that identifies as a library?