Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Full Stack Development with Spring Boot and React - Third Edition

You're reading from  Full Stack Development with Spring Boot and React - Third Edition

Product type Book
Published in Apr 2022
Publisher Packt
ISBN-13 9781801816786
Pages 378 pages
Edition 3rd Edition
Languages
Author (1):
Juha Hinkula Juha Hinkula
Profile icon Juha Hinkula

Table of Contents (22) Chapters

Preface 1. Part 1: Backend Programming with Spring Boot
2. Chapter 1: Setting Up the Environment and Tools – Backend 3. Chapter 2: Understanding Dependency Injection 4. Chapter 3: Using JPA to Create and Access a Database 5. Chapter 4: Creating a RESTful Web Service with Spring Boot 6. Chapter 5: Securing and Testing Your Backend 7. Part 2: Frontend Programming with React
8. Chapter 6: Setting Up the Environment and Tools – Frontend 9. Chapter 7: Getting Started with React 10. Chapter 8: Consuming the REST API with React 11. Chapter 9: Useful Third-Party Components for React 12. Part 3: Full Stack Development
13. Chapter 10: Setting up the Frontend for Our Spring Boot RESTful Web Service 14. Chapter 11: Adding CRUD Functionalities 15. Chapter 12: Styling the Frontend with React MUI 16. Chapter 13: Testing Your Frontend 17. Chapter 14: Securing Your Application 18. Chapter 15: Deploying Your Application 19. Chapter 16: Best Practices 20. Assessments 21. Other Books You May Enjoy

Chapter 6: Setting Up the Environment and Tools – Frontend

This chapter describes the development environment and tools that are needed for React and are required so that you can start frontend development. In this chapter, we will create a simple starter React app by using the create-react-app starter kit, which is developed by Facebook.

In this chapter, we will cover the following topics:

  • Installing Node.js
  • Installing Visual Studio Code
  • Visual Studio Code extensions
  • Creating and running a React.js app using create-react-app
  • Modifying the React app

Technical requirements

In this book, we are using the Windows OS, but all the tools we use are available for Linux and macOS as well.

The following GitHub link will also be required: https://github.com/PacktPublishing/Full-Stack-Development-with-Spring-Boot-and-React/tree/main/Chapter06.

Installing Node.js

Node.js is an open source, JavaScript-based server-side environment. Node.js is available for multiple operating systems, such as Windows, macOS, and Linux, and is required to develop React apps.

The Node.js installation package can be found at https://nodejs.org/en/download/. Download the latest Long-Term Support (LTS) version for your operating system. In this book, we are using the Windows 10 operating system, and you can get the Node.js MSI installer for it, which makes installation really straightforward.

When you execute the installer, you will go through the installation wizard, and you can do so using the default settings:

Figure 6.1 – Node.js installation

Once the installation is complete, we can check that everything proceeded correctly. Open PowerShell, or whatever terminal you are using, and type the following commands:

node -v 
npm -v

These commands should show you the installed versions of Node.js and npm...

Installing VS Code

Visual Studio Code (VS Code) is an open source code editor for multiple programming languages. VS Code was developed by Microsoft. There are a lot of different code editors available, such as Atom and Brackets, and you can use something other than VS Code if you are familiar with it. VS Code is available for Windows, macOS, and Linux, and you can download it from https://code.visualstudio.com/.

Installation for Windows is done with the MSI installer, and you can execute the installation with default settings. The following screenshot shows the workbench of VS Code. On the left-hand side is the activity bar, which you can use to navigate between different views. Next to the activity bar is a sidebar that contains different views, such as the project file explorer.

The editor takes up the rest of the workbench:

Figure 6.3 – VS Code workbench

VS Code provides an integrated terminal that you can use to create and run React apps....

Creating and running a React app

Now that we have Node.js and the code editor installed, we are ready to create our first React.js app. We are using Facebook's create-react-app (https://github.com/facebook/create-react-app) kit for this. Here are the steps you need to follow in order to make your first app:

  1. Open PowerShell or a terminal that you use and type the following command:
npx create-react-app myapp

This command creates a React app named myapp. The npm package runner is npx and, when you're using it, you don't have to install the package before running it:

Figure 6.7 – create-react-app

  1. Once the app has been created, move it into your app folder:
cd myapp
  1. Then, we can run the app with the following command. This command runs the app in the 3000 localhost port and opens the app in a browser:
npm start
  1. Now, your app is running, and you should see the following page in your browser...

Summary

In this chapter, we installed everything that is needed to embark on our frontend development with React.js. First, we installed Node.js and the VS Code editor. Then, we used the create-react-app starter kit to create our first React.js app. Finally, we ran the app and demonstrated how to modify it. This is just an overview of the app's structure and modification, and we will continue this in the following chapters.

In the next chapter, we will familiarize ourselves with the basics of React programming. In JavaScript, we will be using ES6 syntax because it provides several features that make coding cleaner.

Questions

  1. What are Node.js and npm?
  2. How do you install Node.js?
  3. What is VS Code?
  4. How do you install VS Code?
  5. How do you create a React.js app with create-react-app?
  6. How do you run a React.js app?
  7. How do you make basic modifications to your app?

Further reading

Packt has other great resources available for learning about React. These are as follows:

lock icon The rest of the chapter is locked
You have been reading a chapter from
Full Stack Development with Spring Boot and React - Third Edition
Published in: Apr 2022 Publisher: Packt ISBN-13: 9781801816786
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}