DEV Community

Discussion on: How I moved from React to Svelte

Collapse
 
shanwshaw profile image
shawnshaw

I only need CSR(client side rendering) and was unhappy with Svelte's SSR-first approach, now React is becoming SSR-first as well, I might need go back to Vue.js which remains to be the only framework that separates its SSR work from its core that remains to be CSR only.

So no svelte for me for sure, I wasted a few months with it unfortunately. I do not need to set flags here and there and read your SSR content from Sveltekit to get a CSR out, it makes things unnecessarily complicated for my needs.

Collapse
 
webjose profile image
José Pablo Ramírez Vargas

It seems that you believe SvelteKit is the only way to go in Svelte. It is not. SvelteKit is made to be SSR first. Just do regular Vite + Svelte projects with npm create vite@latest.

Collapse
 
kedzior_io profile image
Artur Kedzior

Too bad you had bad experience with it but it seems that your problem is a matter of quick configuration change to static adapter and that's it:
kit.svelte.dev/docs/adapter-static

... with Svelte's SSR-first approach, now React is becoming SSR-first as well ...

dev.to/mandrasch/rich-harris-expla...

I might need go back to Vue.js which remains to be the only framework that separates its SSR work from its core that remains to be CSR only.

Yeah Vue is great and I have used for years injecting "reactivity" into ASP.Net Core Razor pages.

As an alternative good friend of mine uses this for his startup: lit.dev . He has been praising it for simplicity.

Collapse
 
shanwshaw profile image
shawnshaw

tried that and dislike sveltekit since I need zero SSR get involved.

so I went back to svelte, used svelte-spa-router to do client side routing(by the way, can svelte add a client side router by default), then I was looking for a state management solution(is context api my only option for CSR state management?), then for more options on UI libs(sveltestrap)...

my hope is that, svelte adds a client side routing built-in to keep its svelte CSR friendly, has some nice state management lib for the CSR, and keep SSR to sveltekit instead of svelte core, just do not sell sveltekit as CSR solution, it is not.

Thread Thread
 
webjose profile image
José Pablo Ramírez Vargas

For state management, use Svelte stores:

// stores/myCounter.js
import { writable } from 'svelte/store';

export myCounter = writeable(0);
Enter fullscreen mode Exit fullscreen mode

Then import anywhere you need the counter.

As for routing, there won't be an official CSR router. Only SvelteKit has routing. If you need routing, you'll find 2 or 3 options to choose from if you surf the WWW.