I have been building sveltekit and I enocuntered this where sveltekit wont work if you use localstorage API directly because our sveltekit will be running in both client and server and server node.js will pose an error for undefined localStoage API
I have looked for this in stackoverflow and I was not able to find the exact answer anywhere. But then I encountered a stackoverflow question after a lot of searching and here is the solution