Why React, Vite and what we mean by "large scale apps" in this book.
Declarative code structure: React uses a declarative syntax, making it easier for developers to understand how the UI should react to changes in data.
Reusable components: React's component-based architecture allows for building reusable UI components, making it easier to maintain and scale the codebase.
Virtual DOM: React uses a virtual DOM, which optimizes updates and rendering, resulting in improved performance compared to directly manipulating the actual DOM.
Server-side rendering: React allows for server-side rendering, improving the initial load time and making it easier to optimize search engine optimization (SEO).
Large community: React has a large and active community, which means developers have access to a wealth of resources, including tutorials, libraries, and support.
- Faster build times and development experience compared to traditional bundlers.
- Lower initial load times, as only the essential code is loaded
- Improved build size, as Vite only includes the necessary code
- Lightweight and optimized for modern web development.
When we refer to "large scale apps", we mean applications that have a large code base, a large number of users, and a wide range of functionality. These applications typically require efficient and scalable code that can handle high traffic and large amounts of data.
In this kind of projects there are several common concerns that arise, such as:
- Code maintenance and scalability
- Code quality and performance
- Code organization and structure
To address these concerns, here we will outline best practices for code organization and structure, such as using a centralized state manager and implementing strong-type checking with TypeScript. Additionally, we will focus on writing unit tests for our models and components, which will help improve code quality and catch bugs early in the development process.
Our ultimate goal is to build a foundation that can handle the demands of our app and be easy to expand and maintain as the code base grows.
The primary aim of this book is to guide you through the process of building a scalable React application by following best practices for project structure, file organization, naming conventions, state management, type checking with TypeScript, and compositional approaches using hooks.
Throughout the chapters, we will grow our simple project into a robust, large-scale application that is easy to expand and maintain, showcasing how patterns, conventions, and strategies can lay a solid foundation and keep the code organized and uncluttered.
We will build a TypeScript API client that can seamlessly switch between serving static mock data and communicating with a live API, allowing for front-end development to commence even before the back-end API is fully functional. Additionally, we will delve into topics such as internationalization, localization, and advanced techniques, to round out our comprehensive guide to building a scalable React application.
IMPORTANT: We will initially write code that allows us to achieve the desired functionality quickly, even if it requires more code, but then we constantly "rework" it (refactoring) to improve it and find solutions that allow us to reduce the amount of code used, or to organize it in a clear and easy way that is easy to expand and maintain. So arm yourself with a lot of patience!
The audience for this book is from beginners with some experience in MV* applications, to intermediate developers. The format is similar to a cookbook, but instead of individual recipes we'll go through creating a project and keep enhancing, refactoring, and make it better as we move forward to more advanced chapters to show different patterns, architectures, and technologies.
I will highlight most terms or names in bold, rather than define different fonts/styles depending on whether a term is code, or a directory name or something else.
I would like to thank my son for helping me proof read and validate the steps in each chapter by building the same project. I also would like to thank all the developers that over the time helped me correct things in the book and provided valuable feedback.
Official website: https://reactjs.org ↩︎