Kuan

September 28, 2022

Magic in SvelteKit

Magic sounds like a good thing, a wonderful thing that magically improved stuff. Not in building software though. When I call something "magic" in doing software development, it means I don't understand why something happens the way it is. Not always, but under the context that I thought it should have behaved the other way around.

There are situations in SvelteKit where some codes will run in the server, some will run in the client. There are rules and documentation that I need to understand to be really sure when and why the lines of code failed because it was ran in the server but not the client. I tried to read it before, but I am not smart enough to get the gist of it. 

So I ran into a similar situation again. My page showed the wrong thing when I thought it shouldn't be like that when reading my code. Because I relied on local storage when determining whether to show something or not. I'd need to use a special `browser` environment boolean to make sure it ran in the browser when I figure out the flag.

This is magic to me. I cast the wrong spell and now I don't understand the effect my spell made. Now I need to read deeper into the tome. I hate magic.

About Kuan

Web developer building with Flutter, Svelte and JavaScript. Recently fell in love with functional programming.

Malaysian. Proud Sabahan. Ex game developer but still like playing games.

New found hobby is outdoor camping with my love.