- Server component can run at build time. React can render all component a build time.
- Nextjs: Based on mode: 'none', 'standalone', 'export'. 'export' can deploy on static host.
- Flow:
your source files
│
├─ Server Components run here ◄── "before bundling", on the server
│
▼
bundling (webpack/Turbopack) ◄── packages Client Component code
│
▼
JS bundle downloaded by browser ◄── Client Components run here
- Server component can run on a webserver during request for a page. "Server" component will be run on server, so it can access database without API.
- Async server component
- Server component is ran on server, so it don't have browser APIs & can't use useState => Client component