Repository: jasongitmail/svelte-vs-next
Branch: main
Commit: 19430ba74784
Files: 2
Total size: 64.9 KB
Directory structure:
gitextract_p3i_gtff/
├── .gitignore
└── README.md
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
.vscode
package.json
unused
================================================
FILE: README.md
================================================
# SvelteKit vs NextJS
Comparison of major features in SvelteKit vs NextJS.
Goals: fast, easy, convention over configuration, & batteries included.
Overwhelming choices are bad versus providing a clear path forward.
| | SvelteKit | NextJS | Winner | Notes |
| ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| UI lib | [Svelte](https://svelte.dev/) | [React](https://reactjs.org/)
(or [Preact](https://preactjs.com)) | SvelteKit | Svelte offers faster DOM updates, smaller KB client size, _much_ easier cross-component state management, ability to abstract responsive state into external files, etc. Svelte5 has Runes (signals) 🎉, React does not have an equivalent yet. |
| Dev: Hot reload | [🟢](https://kit.svelte.dev/docs/faq#how-do-i-use-hmr-with-sveltekit) | [🟢](https://nextjs.org/docs/architecture/fast-refresh) | -- | I.e. Auto reload on file save. |
| Dev: O(1) hot reload | [🟢 Vite](https://vitejs.dev/) | [🟢 🚧 Turbopack (\*not enabled by default)](https://nextjs.org/docs/architecture/turbopack) | SvelteKit | I.e. Processes only the changed files. Fast even in big projects. \*Update `package.json` to enable Turbopack: `"dev": "next dev --turbo"`. |
| Dev: "Fast refresh" | [🟢 🚧 (not enabled by default)](https://kit.svelte.dev/docs/faq#how-do-i-use-hmr-with-sveltekit) | [🟢](https://nextjs.org/docs/basic-features/fast-refresh) | NextJS | I.e. UI state preserved across reloads. |
| Dev: Write modern JS | [🟢](https://svelte.dev/docs#compile-time) | [🟢](https://nextjs.org/docs/advanced-features/compiler) | -- | |
| Dev: A11y console hints | [🟢](https://svelte.dev/docs#accessibility-warnings) | ❌ | SvelteKit | |
| Dev: Prettier | [🟢](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode) | [🟢](https://nextjs.org/docs/basic-features/eslint#prettier) | -- | For `.svelte` or `.jsx` files, respectively. For SvelteKit, install [`Svelte for VSCode`](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode) extension. |
| Prod: Bundler | [🟢](https://svelte.dev/docs#compile-time) | [🟢](https://nextjs.org/docs/advanced-features/compiler) | -- | E.g. Minify assets, etc. Both are enabled by default. When [RollDown](https://rolldown.rs/) (Rust) is ready in 2024, Svelte will be able to switch from Rollup+ESbuild to RollDown for even faster production builds. |
| Prod: Auto code splitting, per route | [🟢](https://kit.svelte.dev/docs/performance) | [🟢](https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#1-code-splitting) | -- | I.e. Auto code split JS & CSS per route & bundle appropriately. |
| Prod: Build adapters for different hosts | [🟢](https://kit.svelte.dev/docs/adapters) | ❌ | SvelteKit | SvelteKit provides easy portability to many hosts. NextJS works best with Vercel. |
| KB size: Hello World | 🟢 46.3 (25.6 gzip) with CSR\*
🟢 2.9 (3.3 gzip) without CSR (1.8kb of this is the favicon; shows as bigger with gzip in Chrome) | ❌ 336.3 (131.3 gzip) (includes a 9.7kb favicon 👀)\* | SvelteKit | - \*CSR is "client side router".
- SvelteKit updated Aug 25, 2023 using SvelteKit 1.23 & Svelte 4.
- NextJS updated Aug 25, 2023 using App Router, NextJS 13.4.19, & React 18.2.0.
- Both tests return HTML of `
hello world
` and exclude CSS. | | KB size: "Real World" app | too out of date | too out of date | -- | Out of date; PR welcome. \*Mar 13, 2021