2021 was a year of accelerated restructuring across the frontend ecosystem: Vue 3 completed its ecosystem, Angular 12/13 finished the Ivy migration, and Vite went from an emerging tool to a mainstream choice. Standing at the end of 2021, let's predict what will happen in 2022.
React 18: Concurrent Rendering Is Here
React 18 released its Alpha in June 2021, and the stable version is expected in early 2022. The most important change is concurrent rendering — React can interrupt rendering to prioritize more urgent updates:
// React 18 新特性:useTransition
function SearchPage() {
const [query, setQuery] = useState("");
const [results, setResults] = useState([]);
const [isPending, startTransition] = useTransition();
const handleSearch = (e) => {
const value = e.target.value;
setQuery(value); // 立即更新输入框(高优先级)
startTransition(() => {
// 标记为低优先级,可被中断
setResults(performHeavySearch(value));
});
};
return (
<>
<input value={query} onChange={handleSearch} />
{isPending ? <Spinner /> : <ResultList results={results} />}
</>
);
}
Other new React 18 APIs:
useDeferredValue: likestartTransition, but for values rather than functionsuseId: generates a stable unique ID (SSR-hydration safe)Suspenselist ordering (SuspenseList)- Streaming SSR (
renderToPipeableStream)
Vue 3 Becomes the Default
In Q1 2022, Vue 3 will become the default version installed by npm install vue (today it's still Vue 2). This means:
# 2022 年之后
npm install vue # 安装 Vue 3(目前会安装 Vue 2)
npm install vue@2 # 明确指定 Vue 2
Vue 3's ecosystem filled in its last few missing pieces in 2021:
Piniabecame the recommended state-management solution (replacing Vuex)Vue Router 4stabilizedNuxt 3Beta released (built on Vue 3 + Vite)
Vite Becomes the Go-To Build Tool
After Vite 2 shipped in 2021, adoption rose sharply. In 2022 it is expected to become the first choice for new projects:
// vite.config.ts
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import react from "@vitejs/plugin-react";
export default defineConfig({
plugins: [vue()], // 或 react()
build: {
rollupOptions: {
output: {
// 自动代码分割
manualChunks: {
vendor: ["vue", "vue-router", "pinia"],
},
},
},
},
});
Vite vs Webpack cold-start comparison (medium project):
Webpack 5(with cache):~6s
Vite:~300ms
原因:Vite 开发模式不打包,直接利用浏览器原生 ESM
Rise of Meta-Frameworks
2022 will be the breakout year for meta-frameworks:
| Framework | Based on | Status (early 2022) |
|---|---|---|
| Next.js 12 | React | Production-stable, #1 market share |
| Nuxt 3 | Vue 3 + Vite | RC stage |
| SvelteKit | Svelte | Beta |
| Remix | React | Open-sourced Nov 2021 |
| Astro | Framework-agnostic | Beta |
Remix deserves special attention — it rethinks how data loading works:
// Remix 的 loader 函数:在服务端运行,数据直接注入组件
export async function loader({ params }) {
const post = await db.post.findUnique({ where: { id: params.id } });
return json(post);
}
export default function Post() {
const post = useLoaderData(); // 自动是服务端数据
return <article>{post.content}</article>;
}
TypeScript Continues to Penetrate Deeper
TypeScript's downloads grew about 60% year over year in 2021; for 2022 we expect:
- Vue 3's official docs to go fully TypeScript
- the
satisfiesoperator (TS 4.9 draft, for more precise type checking) - more frameworks to treat TypeScript as a first-class citizen
Summary
The main theme of frontend in 2022 is maturity — React 18's concurrent rendering, Vue 3's complete ecosystem, Vite becoming standard, and the divergence of meta-frameworks. The seeds planted in 2021 (Vite, SolidJS, Remix) will bear fruit in 2022. For frontend developers, the most worthwhile investments are: a deep understanding of concurrent rendering, familiarity with the Vite ecosystem, and taking TypeScript type design seriously. Here's to writing better code in 2022.
