Why Next13?

2023-04-06

I love Svelte, so why did I choose Next13 over SvelteKit for this website?

main image for blog post

I have to start with this: I love Svelte. In my experience, it is the simplest, cleanest way to design front-end UIs, and it makes the most sense to me. It's a joy to work with because unlike React, it doesn't hold itself down to the limitations of JavaScript. Its compiled nature allows it to "break" traditional JavaScript and do all kinds of crazy abstractions that make the developer experience of using Svelte so much nicer. With all that said, it's still a young and emerging library, and even younger still is the metaframework built to take advantage of it: SvelteKit.

I actually tried using SvelteKit

My choice of Next13 is not for lack of trying. I originally built this project in SvelteKit, but ultimately I had to migrate over to Next13 in the early stages of development. I'm using Sanity.io as the CMS platform for this site, and for blog posts like this, they use a format called PortableText. There are libraries you can download that can covert the PortableText data that the API gives you into renderable HTML, and there's a SvelteKit version available. The issue is that when I tried using it, I got an error every time I reloaded a page that uses PortableText. The initial page load was fine, but any reload attempt would cause a 500 Internal Server error.

Next isn't that stable either

When I migrated everything to Next13, I decided to live a little on the edge and use the new App Router that's still in beta. I ran into some issues here as well. Tailwind wasn't working at first, and I was suffering from problems that constantly required me to restart the dev server. The difference however, is that the community for Next is much larger, and therefore there are more resources to help with issues. By virtue of being the older and more established technology, Google searches and Stack Overflow queries of Next problems return many more solutions than the same for SvelteKit related issues.

It's not SvelteKit's fault

SvelteKit isn't at fault for the specific problem I encountered. I'm almost certain that Sanity's PortableText library was at fault. However, it must be said that these things will continue to happen until SvelteKit gets wider adoption. Who knows which library "made for SvelteKit" will break next? (no pun intended).

Conclusion

I love SvelteKit. I have come to also love Next13. I'm still head over heels for Svelte, especially compared to React. But issues that are systemic of the small community can sometimes hinder my ability to ship SvelteKit apps to production. However, I won't stop trying. For future projects, I want to experiment with both to see which one can best suit that project. I'm hopeful that in the future, SvelteKit will be the solution I gravitate towards for building full stack projects.