Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

430
Views
Using Require with React in a web page without node

I know this might be a silly question to some of you, but I am beginner in React, and I wish to create a really simple application. I found a sample in which every component is saved in a separate js file, which looks very good for modularity and re-usage.

The only thing I need to take care of now is using export/require. However, I don't need to be dependent on nodejs. I just need a simple html/js application that can run on any cheap web server.

I read somewhere that I can use "Browserify", but after looking at it, it seems like a node library.

Is there any library that I can use from a web page (via cdn for example) that allow me to use require? If not, does that mean I can not separate react components in different files?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

However, I don't need to be dependent on nodejs.

Use NodeJS. It is how React applications are designed to be built.

I just need a simple html/js application that can run on any cheap web server

NodeJS is only required at build time. You run it on your development workstation. The output is static files that you can upload to any webserver.

(NB: React applications are often designed to make HTTP requests to get dynamic data. Some tutorials cover using Node to build a server to listen for and make responses to those requests. Make sure you don't conflate the program to transpile the React application to ES5 (which runs at build time) with the program to run a webserver (at runtime) even if both are written using Node).

over 4 years ago · Santiago Trujillo Report

0

If you don't want to use Node, you can use webpack: https://webpack.github.io/ you will generate a static/bundle.js . If you want to learn more about it, I sugest http://survivejs.com/

over 4 years ago · Santiago Trujillo Report

0

What you need is a build step that packs the separate files into one or more packages that can be loaded in the browser. Browserify can be used to do that, but WebPack is also popular.

These tools require some configuration, so I think that the best way to start is with a tool like create-react-app which is easy to install and has commands for developing as well as packing your app for deployment.

It uses webpack internally (along with some other tools) but saves you the hassle of configuring it yourself. If at any time you need advanced configurations beyond what create-react-app provides, it has an 'eject' command that exposes the raw configuration files.

Getting started is simple (taken from their readme):

npm install -g create-react-app  

create-react-app my-app
cd my-app/
npm start
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!