Full Stack Development with Spring Boot 3 and React - Fourth Edition

Book description

Get up and running with the Spring Boot and React stack – build an app from start to finish, test the frontend and backend, and deploy. Now with TypeScript code! Purchase of the print or Kindle book includes a free PDF eBook

Key Features

  • Use Spring Boot 3 to create powerful, complex, and secure backends for your applications
  • Leverage React to build slick, high-performance frontends
  • Get introduced to TypeScript, Vite, and React Query for React development

Book Description

If you’re an existing Java developer who wants to go full stack or pick up another frontend framework, this book is your concise introduction to React. In this three-part build-along, you’ll create a robust Spring Boot backend, a React frontend, and then deploy them together.

This new edition is updated to Spring Boot 3 and includes expanded content on security and testing. For the first time ever, it also covers React development with the in-demand TypeScript.

You’ll explore the elements that go into creating a REST API and testing, securing, and deploying your applications. You’ll learn about custom Hooks, third-party components, and MUI.

By the end of this book, you'll be able to build a full stack application using the latest tools and modern best practices.

What you will learn

  • Make fast and RESTful web services powered by Spring Data REST
  • Create and manage databases using ORM, JPA, Hibernate, and more
  • Explore the use of unit tests and JWTs with Spring Security
  • Employ React Hooks, props, states, and more to create your frontend
  • Harness the Material UI component library to customize your frontend
  • Use the fetch API, Axios, and React Query for networking
  • Add CRUD functionality to your apps
  • Deploy your apps using AWS and Docker

Who this book is for

This book is for Java developers who have basic familiarity with Spring Boot but don’t know where to start when it comes to building full stack applications. Basic knowledge of JavaScript and HTML will help you to follow along. You'll also find this book useful if you're a frontend developer with knowledge of JavaScript basics and looking to learn full stack development, or a full stack developer experienced in other technology stacks looking to learn a new one.

Table of contents

  1. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Get in touch
  2. Part I: Backend Programming with Spring Boot
  3. Setting Up the Environment and Tools – Backend
    1. Technical requirements
    2. Installing Eclipse
    3. Understanding Gradle
    4. Using Spring Initializr
      1. Creating a project
      2. Running the project
      3. Spring Boot development tools
      4. Logs and problem-solving
    5. Installing MariaDB
    6. Summary
    7. Questions
    8. Further reading
  4. Understanding Dependency Injection
    1. Technical requirements
    2. Introducing dependency injection
    3. Using dependency injection in Spring Boot
    4. Summary
    5. Questions
    6. Further reading
  5. Using JPA to Create and Access a Database
    1. Technical requirements
    2. Basics of ORM, JPA, and Hibernate
    3. Creating the entity classes
    4. Creating CRUD repositories
    5. Adding relationships between tables
    6. Setting up a MariaDB database
    7. Summary
    8. Questions
    9. Further reading
  6. Creating a RESTful Web Service with Spring Boot
    1. Technical requirements
    2. Basics of REST
    3. Creating a RESTful web service with Spring Boot
    4. Using Spring Data REST
    5. Documenting a RESTful API
    6. Summary
    7. Questions
    8. Further reading
  7. Securing Your Backend
    1. Technical requirements
    2. Understanding Spring Security
    3. Securing your backend with a JSON Web Token
      1. Securing the login
      2. Securing the other requests
      3. Handling exceptions
      4. Adding a CORS filter
    4. Role-based security
    5. Using OAuth2 with Spring Boot
    6. Summary
    7. Questions
    8. Further reading
  8. Testing Your Backend
    1. Technical requirements
    2. Testing in Spring Boot
    3. Creating test cases
      1. Testing with Gradle
    4. Test-driven development
    5. Summary
    6. Questions
    7. Further reading
  9. Part II: Frontend Programming with React
  10. Setting Up the Environment and Tools – Frontend
    1. Technical requirements
    2. Installing Node.js
    3. Installing Visual Studio Code
      1. VS Code extensions
    4. Creating and running a React app
      1. Modifying a React app
    5. Debugging a React app
    6. Summary
    7. Questions
    8. Further reading
  11. Getting Started with React
    1. Technical requirements
    2. Creating React components
      1. Examining our first React app
    3. Useful ES6 features
      1. Constants and variables
      2. Arrow functions
      3. Template literals
      4. Object destructuring
      5. Classes and inheritance
    4. JSX and styling
    5. Props and state
      1. Props
      2. State
      3. Stateless components
    6. Conditional rendering
    7. React hooks
      1. useState
        1. Batching
      2. useEffect
      3. useRef
      4. Custom hooks
    8. The Context API
    9. Handling lists with React
    10. Handling events with React
    11. Handling forms with React
    12. Summary
    13. Questions
    14. Further reading
  12. Introduction to TypeScript
    1. Technical requirements
    2. Understanding TypeScript
      1. Common types
      2. Functions
    3. Using TypeScript features with React
      1. State and props
      2. Events
    4. Creating a React app with TypeScript
      1. Vite and TypeScript
    5. Summary
    6. Questions
    7. Further reading
  13. Consuming the REST API with React
    1. Technical requirements
    2. Promises
      1. async and await
    3. Using the fetch API
    4. Using the Axios library
    5. Practical examples
      1. OpenWeather API
      2. GitHub API
    6. Handling race conditions
    7. Using the React Query library
    8. Summary
    9. Questions
    10. Further reading
  14. Useful Third-Party Components for React
    1. Technical requirements
    2. Installing third-party React components
    3. Working with AG Grid
    4. Using the Material UI component library
    5. Managing routing with React Router
    6. Summary
    7. Questions
    8. Further reading
  15. Part III: Full Stack Development
  16. Setting Up the Frontend for Our Spring Boot RESTful Web Service
    1. Technical requirements
    2. Mocking up the UI
    3. Preparing the Spring Boot backend
    4. Creating the React project for the frontend
    5. Summary
    6. Questions
    7. Further reading
  17. Adding CRUD Functionalities
    1. Technical requirements
    2. Creating the list page
      1. Fetching data from the backend
      2. Using environment variables
      3. Adding paging, filtering, and sorting
    3. Adding the delete functionality
      1. Displaying a toast message
      2. Adding a confirmation dialog window
    4. Adding the add functionality
    5. Adding the edit functionality
    6. Exporting the data to CSV
    7. Summary
    8. Questions
    9. Further reading
  18. Styling the Frontend with MUI
    1. Technical requirements
    2. Using the MUI Button component
    3. Using the MUI Icon and IconButton components
    4. Using the MUI TextField component
    5. Summary
    6. Questions
    7. Further reading
  19. Testing React Apps
    1. Technical requirements
    2. Using Jest
    3. Using the React Testing Library
    4. Using Vitest
      1. Installing and configuring
      2. Running our first test
      3. Testing our Carlist component
    5. Firing events in tests
    6. End-to-end testing
    7. Summary
    8. Questions
    9. Further reading
  20. Securing Your Application
    1. Technical requirements
    2. Securing the backend
    3. Securing the frontend
      1. Creating a login component
      2. Implementing REST API calls
      3. Refactoring duplicate code
      4. Displaying an error message
      5. Logging out
    4. Summary
    5. Questions
    6. Further reading
  21. Deploying Your Application
    1. Technical requirements
    2. Deploying the backend with AWS
      1. Deploying our MariaDB database
      2. Deploying our Spring Boot application
    3. Deploying the frontend with Netlify
    4. Using Docker containers
    5. Summary
    6. Questions
    7. Further reading
  22. Other Books You May Enjoy
  23. Index

Product information

  • Title: Full Stack Development with Spring Boot 3 and React - Fourth Edition
  • Author(s): Juha Hinkula
  • Release date: October 2023
  • Publisher(s): Packt Publishing
  • ISBN: 9781805122463