React FrameWorks: Crash Course
What is a framework?
React isn't a Framework!
Why?
Frameworks have documented standards!
React Router V7
Maintained by : Shopify - The Remix Team
// route("products/:pid", "./product.tsx") or /app/products/:pid ;
import type { Route } from "./+types/product";
export async function loader({
params,
}: Route.LoaderArgs) {
const res = await fetch(`/api/products/${params.pid}`);
const product = await res.json();
return product;
}
export default function Product({
loaderData,
}: Route.ComponentProps) {
const { name, description } = loaderData;
return (
<div>
<h1>{name}</h1>
<p>{description}</p>
</div>
);
}- Supports CSR, SSR, SSG
- Overall flexibility
- Includes a lot of building blocks
Pros
- Loader pattern can be jarring
- You have to roll some things yourself
- Lack of RSC (For now)
Cons
Next.js
Maintained by : Vercel
// app/blog/page.tsx
export default async function Page() {
const data = await fetch('https://api.vercel.app/blog')
const posts = await data.json()
return (
<ul>
{posts.map((post) => (
<li key={post.id}>{post.title}</li>
))}
</ul>
)
}- Supports CSR (kind of), SSR, SSG
- Opinionated guardrails + libraries
- RSC support
Pros
- Defaults to RSCs
- Difficult to self host
- Feels awkward if you need a lot of client-side JS
CONS
TanStack Start
Maintained by : Tanner Lindsley + team
// src/routes/index.tsx
import { createFileRoute, useRouter } from "@tanstack/react-router";
import { createServerFn } from "@tanstack/react-start";
const countEndpoint = "/api/count";
const getCount = createServerFn({ method: "GET" }).handler(async () => {
const response = await fetch(countEndpoint);
const text = await response.text();
return parseInt(text || "0");
});
export const Route = createFileRoute("/")({
component: Home,
loader: async () => await getCount(),
});
function Home() {
const router = useRouter();
const count = Route.useLoaderData();
return (
<div>{count}</div>
);
}- Supports very lightweight SSR
- SOLID Type Safety
- RPCs
Pros
- Lacks RSC support
- RPCs + loaders are a little jarring
- Feels more verbose?
- Lacks library support
Cons
RRV7
Flexibility
Roll your own stuff
Unsure of SSR vs CSR
Loaders
Next.js
RSCs
Heavy guardrails
Opinionated libraries
TanStack Start
Lightweight SSR
Type Safety
RPCs / loaders
You're into indie stuff!
Cheatsheet
Please use a framework!
Thank you!
React Frameworks: Crash Course
By Sean McQuaid
React Frameworks: Crash Course
- 3