React JS and Spring Boot are two powerful tools that complement each other perfectly for building full-stack web applications. If you're looking to create a modern, reactive frontend coupled with a robust backend, you're in the right place. In this comprehensive tutorial, we'll walk you through building a simple yet illustrative example of a React JS frontend communicating with a Spring Boot backend via REST API.

Before we dive in, ensure you have Node.js, npm, and Java SDK installed on your machine. We'll also use Create React App for bootstrapping our React project and Spring Initializr for our Spring Boot application.

Setting Up the Spring Boot Backend
The first step is to set up our Spring Boot backend with a simple REST API. We'll be using Spring Initializr to initialize our project and adding the necessary dependencies.

After initializing our project, let's create a new `User` entity and a corresponding REST Controller for performing CRUD operations.
Creating the User Entity

In the model package, create a new `User.java` file. This will hold our user data.
```java public class User { private Long id; private String name; private String email; // Getters and setters } ```
Creating the UserController

Next, create a new `UserController.java` file in our controller package. This will handle HTTP requests and responses for our user data.
```java
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/api/users")
public class UserController {
private final UserRepository userRepository;
public UserController(UserRepository userRepository) {
this.userRepository = userRepository;
}
@GetMapping
public List
With our backend set up, it's time to move on to the frontend with React JS.

Setting Up the React JS Frontend
We'll use Create React App to initialize our React project. After initializing, navigate to your project directory and install Axios, which we'll use to handle HTTP requests.









```bash npx create-react-app my-app cd my-app npm install axios ```
Creating the User List Component
In the src folder, create a new file called `UserList.js`. This component will fetch and display our list of users.
```jsx import React, { useEffect, useState } from 'react'; import axios from 'axios'; const UserList = () => { const [users, setUsers] = useState([]); useEffect(() => { const fetchUsers = async () => { const response = await axios.get('http://localhost:8080/api/users'); setUsers(response.data); }; fetchUsers(); }, []); return (
User List
{users.map(user => (
{user.name}
{user.email}
Integrating the User List Component
Now, let's integrate our `UserList` component into our main `App.js` file.
```jsx import React from 'react'; import './App.css'; import UserList from './UserList'; function App() { return (
Congratulations! You've just created a simple React JS frontend communicating with a Spring Boot backend via REST API. This hands-on example sets the stage for building more complex, full-stack applications using these powerful tools. Happy coding!