I've been using Svelte since v3 was released almost daily. I've been using v5 for the past couple of weeks and it's fantastic. The biggest improvement IMO is that you can now write reactive logic intuitively outside your components and it just works without needing to use complex machinery or patterns like Mobx, Redux, or Vuex. I've been doing frontend since the 90s and used everything under the sun. Svelte 5 is the…
Svelte 5 Released
141–150 of 254 posts
Re: Svelte 5 Released
#142Re: Svelte 5 Released
#143Why should someone use Svelte 5 over Vue 3? Performance might be the only reason IMO, but once Vue Vapor is release that will most likely not be an advantage. The Vue3 and Svelte 5 API are almost the exact same, but Vue can be used in TS/JS and Svelte 5 can't. I do think SvelteKit is better than Nuxt by a lot. Maybe that's a big advantage.
Re: Svelte 5 Released
#144If you use "if !browser" with sveltes browser object, the things inside that branch will only run on the server.
But because svelte is compiled, these functions get compiled to two different versions, one for the server and one for the client, in which that if statement has been completely compiled out. That in itself isn't bad but it's weird that normal code and control flow influences compilation. In other languages this would be a macro or something that clearly expresses that it's metaprogramming.
Then there are some other weird things like props being merged and potentially overwriting each other in a deep level. But that is by design and can be reasoned about.
What also felt weird to me is that there is no recommended way to do initialization logic such as reading in a config, reading from the environment and preparing something for the rest of the lifetime of the application.
Has anyone had similar experiences/confusions when learning SvelteKit?
Re: Svelte 5 Released
#145Considering trying out Vue or Svelte after working with React (hate react). Do they have a batteries included bootstrap with social auth?
> Do they have a batteries included bootstrap with social auth? Nope, but it does have routing!
Re: Svelte 5 Released
#146What's the preffered way to make simple SPAs using Svelte now? I'm using this +layout.ts with sveltekit: > export const ssr = false; export const prerender = false; But it feels awkward for real SPAs - internal applications that have no need for server side rendering.
What's the goal of disabling SSR though? I get that hydrations value is mainly in SEO and a tiny improvement in initial draw speed, but why would you want it disabled, specifically? It's pretty much what you already wrote though. https://kit.svelte.dev/docs/single-page-apps
However, when your app is larger or needs to be faster, you want a dedicated backend for your API. Then, you can choose a more secure and more scalable language like C#, Go or Kotlin.
Regarding performance, many SSR advocates (don't forget there's a huge business behind this stuff) don't do the math correctly. It's faster (or as fast) to host a SPA on a CDN and get the data from your backend close to your DB. Let me explain assuming the page containing personal data from the user:
1. The user never visited the site. Getting the SPA from the CDN is very fast. Even if you need to get the JS via a second round trip. Then to get the user data is a much slower second roundtrip to the backend server. With SSR, you also have a first much slower roundtrip to the backend to get your SSR site (maybe even another one for hydration!). Then there's a second slower roundtrip to the server to get the user data. This request is slower than getting the data from a fast API backend in the SPA case. So, if the user never visited the site, you need basically two requests anyway: One for the app another for the data. How else should the backend know, what data to return. With an SPA on a CDN the first request is much faster. I must mention that rendering the SPA is an issue on slow devices. But this is a much smaller problem with Svelte than with React. SEO is probably better with SSR, but no as much as the crawlers are nowadays fast to run the JS.
2. The user has visited the site: The SPA is cached in the browser. Or an eTag validation request goes to the CDN. Very fast. Then, the first relevant request with user auth token goes to the backend to get the user data. With SSR, you get everything with one request. No real world difference there. Both approaches one relevant request. One can argue: Rendering the JS on the client device vs on the Node server. C# or Go backend faster than Next or Sveltekit. But those are not the big numbers.
Now, the big disadvantages of SSR is that you need to run a comparatively slow and not very scalable Node backend. If your app is small, then go for Sveltekit or Next with SSR as the DX is awesome. There's no simpler way to create a fullstack app then Sveltekit. It you have a more complex scenario, most of the time SPA is the way to go.
Re: Svelte 5 Released
#147When I recently looked at SvelteKit, what confused me the most was the universal load function. If you use "if !browser" with sveltes browser object, the things inside that branch will only run on the server. But because svelte is compiled, these functions get compiled to two different versions, one for the server and one for the client, in which that if statement has been completely compiled out. That in itself isn'…
Re: Svelte 5 Released
#148I don't understand how React is so popular, still. With Svelte and Vue, I don't think anybody should do a new project with React.
This is why I think react is still the best: In react you only deal with plain values. You never have to worry about wrapping a value in an observable or calling it in a function with a tracking context. Or .valueing it or whatever. It looks like Svelte 5 is trying to make signals "disappear" but they still leak through. Reading the docs about shallow $state.raw vs deep proxying the default $state rune in svelte 5 ma…
Also RN has no real desktop app story.
Re: Svelte 5 Released
#149I can wholeheartedly recommend Svelte. As someone who can only do vanilla HTML/CSS/JS, it lets me build projects quickly and efficiently without having to learn something complex like React. Case in point this silly side project made in Svelte over a weekend: https://meoweler.com
Few things, for me the domain name is difficult to remember
The page doesn’t fully scroll down for me and the discord button is not accessible on mobile
Other than that the site it nice
Re: Svelte 5 Released
#150I've been using Svelte since v3 was released almost daily. I've been using v5 for the past couple of weeks and it's fantastic. The biggest improvement IMO is that you can now write reactive logic intuitively outside your components and it just works without needing to use complex machinery or patterns like Mobx, Redux, or Vuex. I've been doing frontend since the 90s and used everything under the sun. Svelte 5 is the…
How is mobx complex, its literally plain class for reactive data and wrapping components with observer()