Introducing
Recently i had an opportunity to start a new React project from scratch at my team at Linkedin, so i hopped onto React official documentation and to my surprise Create React App was missing in getting started blog by React team, instead it is been suggested to use a React Frameworks like Next js, Remix or Gatsby.
Sadly no React is not a framework, but just a library which you can use to build reactive components. On the other hand a framework is a collection of libraries with opinionated architecture which helps you a complete production ready app.
You can definitely use React without a framework, in such scenarios CRA (Create React App) is not the recommended way, you should spun up your application with a efficient bundler like Vite or Parcel and add all your required dependencies for routing, data fetching, linting and server side rendering as per your requirements.
In case you have decided to completely ditch React Frameworks, here are a few things you should consider before making your choice, since such types of decisions tend to stick with your project for a long time.
React is often described as un-opinionated, meaning it does not enforce strict guidelines or impose a specific way of structuring code. Instead, it provides developers with the flexibility to choose their preferred tools, libraries, and architectural patterns based on the requirements of their projects. It relies on a lot of libraries for state management, data fetching, routing, linting and testing. This un-opinionated nature of React might look good for hobby projects as it will give you more freedom, but when it comes to creating a production ready application you might spend time evaluating which libraries to pick and choose, onboarding new members to a non standardized react project might take longer
But most importantly as a developer, we would want to spend less time evaluating and managing dependencies and focus more on implementation, while still taking advantage of these latest advancements.Teams utilizing React frameworks can prioritize the development of components and business logic while relying on proven open-source solutions. Frameworks would make a lot of these decisions for you, as well as provide you with tools and components to solve common problems on the web.
Performance is not just related to rendering solutions but also to the way your application loads assets and data from the server and how much of these requests can be parallelized. Alot of our React applications succumb to it.
The network waterfall effect refers to a series of sequential network requests that can significantly degrade user experience, especially on slow networks or devices. In a traditional React application without a framework like Remix, the process typically involves sending a basic HTML file along with multiple JavaScript bundles to the client browser. These JavaScript bundles then recreate the required HTML and render it on the client browser. During this rendering process, a component might realize it needs additional data or another assets from the server, triggering another server request. This can lead to a chain of network requests, where each request depends on the completion of the previous one, resulting in multiple round trips to the server. Here is an interesting blog if you interested to know more about it google-needs-9x-more-time-to-crawl-js-than-html
For the first page request Remix generates all the required HTML on the server by fetching all the required data and assets on the server and just sends the final HTML to the user. For subsequent pages (when user is navigated to another page) Remix knows all the dependencies for a page (JavaScript modules, data, CSS) just from the URL, allowing it to run all queries and load resources in parallel.This approach eliminates the need for multiple round trips and reduces the dependency on the clients network speed. This design significantly improves performance and user experience by minimizing the network waterfall effect.
React performs client side rendering, which means its calculates the final rendered html by fetching assets (css, js files etc) and data on client side. Client side rendering is not a preferred option for users with limited network bandwidth or lower end devices. Even for better SEO ranking, Client side rendering is not preferred since there are few search engine crawlers like Baidu and Yandex are still not indexing client side rendered websites well. Even for Google, indexing of Client side rendered websites takes a lot of time. Here is a blog which says that google took 36 hours to index a static site whereas client side rendered similar site took 313 hours, such indexing delays might be crucial for some use cases.
In such scenarios developers tend to resort to Server Side Rendering (SSR), Static Site Generation (SSG) or React Server Components. I think explaining the difference between all of them and how it helps in performance, deserves its own blog. NextJs and Remix both support SSG and SSR out of the box. Currently NextJs is the only framework to support React Server Components.
Short answer again yes, you can definitely all use rendering strategies without a React Framework, but the amount of effort in implementing these strategies vs simply using a framework would be similar to that of growing sugarcane to produce sugar vs buying it from the supermarket to latter use it in your cake. I would rather perfect my baking skills i.e bussiness logic than building already existing solutions again. Definitely it would be fun to do so for learning purposes but not worth it for the long run. If you dont believe me here is a blog (react-server-components-rsc-no-framework) where we are implementing React Server Components without framework. If you would implement Server components in Next Js, it would be very similar to writing your normal react components.
I hope this blog taught few new things and it was fun reading. See you in next blog, until then Chau.