Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Please someone correct me if I'm wrong. It seems like you can only implement React using the full "modern JS stack", i.e. Node/Webpack/...

So if you want to use it on one page, it's a hard sell to set up all that infrastructure (and document it for the team)

On some sites I've used Vue.js by simply adding a <script> tag with vue.min.js.

On sites already using Gulp or similar, it's pretty simple to incorporate the Vue bundle and use it on one or a few pages.



React can be added to a page with just a script tag in the same way as Vue:

https://reactjs.org/docs/add-react-to-a-website.html

Having said that, React is normally used with JSX syntax, which requires a compile step.

You _can_ use it with "raw" `React.createElement()` calls, but that's generally unwieldy and almost no one does that.

However, there's a very neat library called https://github.com/developit/htm , which is an almost-JSX-compatible syntax that uses JS template literal strings, and requires no compile step.


React can also be used with just script tags. It uses a compiler to turn JSX into a render function (the same as Vue which accepts JSX or HTML) and these compilers are written in JS and can run in the browser. Also modern browsers are much better at supporting JS modules which makes it easier to include other libraries.


This looks like the perfect place to mention my project template used to create Vue 3 apps without the need for Webpack or any other build tool:

https://github.com/arijs/vue-next-example

I already integrated vue-router, and am currently on the process of fully integrating Vue server renderer. I already have a basic usage implemented, where the home page is compiled to a html string, but I still need to make it easy to compile all pages and to implement client-side component hydration.



There is no need to run NodeJS in production with React. In fact, React doesn’t even require a fancy build system (though for anything more than a toy app you’re tempting fate.)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: