Using React With Nodejs

Using React with Node.js

August 20, 2025
By Richard Whitney
Updated: August 20, 2025

Using React with Node.js

React, developed by Facebook in 2013, is ideal for Single Page Applications (SPA's) among other things.

Let's create our first React App:

                            
npx create-react-app myapp

cd myapp
                            
                        

Now, I needed to change the port from the default (3000), and run with HTTPS, so I created a .env file at the root of the app and added

                            
PORT=3008
HTTPS=true
                            
                        

and ran npm start

Since I am running NGINX as a proxy, and I have a certificate installed there, I can go to https://reactapp.domain.com

Here is my first code in React (after editing index.js in the src/ dir):

                            
import React from 'react';
import ReactDom from 'react-dom';
import './index.css';

function Hi(){
    let date = new Date();
    return <h1>Hello {getAge('October 1, 1962') + 1} in {date.getFullYear()}!</h1>
}

function getAge(birth){
    let today = new Date(),
    birthDate = new Date(birth),
    age = today.getFullYear() - birthDate.getFullYear(),
    m = today.getMonth() - birthDate.getMonth();
    if(m < 0 || (m === 0 && today.getDate < birthDate.getDate())){
        age--;
    }
    return  age;
}

ReactDom.render(<Hi/>, document.querySelector('#root'));
                        
                    

Ok, so I have been through the process of setting up a website using React.

To make things simple, I have the css files in src/css and any background images in src/css/images and fonts in src/fonts - this way, in your css files, you can point to any background images or fonts by saying

                            
background-image: url(images/...); or
@font-face {
    font-family: font-name;
    src:url(../fonts/...);
}
                            
                        

Let's Work Together

Ready to start your project? Get in touch and let's discuss how I can help bring your vision to life.

Get In Touch

Call Me

For urgent matters or immediate consultation

480-336-9337

Email Me

For project inquiries and detailed discussions

richard@webrenegade.net

Location

Serving clients locally and nationwide

Scottsdale, Arizona

⚡ Quick Response Guarantee

I typically respond to all inquiries within 24 hours during business days.

Send Me a Message

Fill out the form below and I'll get back to you as soon as possible.

By submitting this form, you agree to receive communication from Web Renegade.

Make a Payment

This form will take you to PayPal. Please use this form to pay with your credit card. Thank you!

Note: You are making a payment to Web Renegade


Description:



Thank you for your business!