When client-side routing is worse than server-side routing

02/04/2021 , 2m, 57s

Hey there friend so today I wanted to talk about something that I've been thinking about a little bit and it is client side routing. So Ryan Florence actually tweeted about this. I think like a year ago or something and and I talked about it recently on a podcast that I was on I think Dev mode FM or something.

But yeah his tweet was basically like I kind of feel like client side routing is a mistake and we're better off with like actually going to get the document on it, you know, full-page refresh basically on every page. AndI I've talked with Ryan Florence about this quite a bit.

And here are just some thoughts that I have about it. And I kind of agree with him sort of. So basically what what I'm thinking is that with client side routing by default or let's take a step back. So like before client side routing goes the thing you'd find a link on the page you'd click on that link and then you would see like the browser would give you some indication that something's happening.

So you'd get the spinner at the top where the favicon is and you'd get.Like some information on the bottom typically telling you that you're waiting on a particular resource and then while that's happening you actually still get to see the page that you were on before. So you still may be able to make use of that information or something or notice something or whatever.

And then when we move to client side routing then pretty often what happens is you click on the link and you immediately navigate to the page that you're going to and then you see a bunch of spinners all over the place. Or even worse you don't see spinners andYou just you land on the page and then things pop into place as they become available and that typically will happen when the developer who worked on the page was on a really fast internet connection just didn't really consider what a loading experience would be like.

And in fact, very very often our designers don't design loading experiences. And so we have to be explicit about it. And so what's interesting is that the the default behavior gives you all the right affordances for the loading state. And when you go to client side routing,You have to opt into giving those affordances so there's some indication that a loading state is showing it's something is loading and you have to worry about when things load and when things pop into place and stuff and so yeah, it's it's a little bit of a step back maybe you just have to be a lot more intentional and so maybe the default of having it do a full page refresh essentially is an entirely a bad one from that perspective and then when you go to client side routing, you just really have to think about those things.

So anyway, just some thoughts hopefully,