Stop Using Routes in SPA Apps like Svelte and Vue

sobPilot
1 min readJul 17, 2020

--

Since I have been using Svelte for most of my applications, it all of a sudden dawned on me that Routes just get in the way.

Under the covers, SPA applications are simply hiding and showing DOM elements to simulate pages. This is the way I developed Windows exe applications. The SPA app should control all of the navigation within the app.

If your app is running in a mobile browser then it makes even more sense to control the flow just like a native app does.

With Svelte it is very easy to use {#if} statements or <svelte:component> to simulate routes and pages. Here is a nice example from twitter on how to do this in Svelte.

The default Svelete template does not include any routes and makes a very compact app. So the next time you start searching for a Router component, just do the navigation yourself!

--

--

sobPilot
sobPilot

Written by sobPilot

A Pilot and Developer. I can't figure out if piloting pays for my development or development pays for my piloting.

No responses yet