When client-side routing is worse than server-side routing - a podcast by Kent C. Dodds

from 2021-02-04T20:44:32

:: ::

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 Florenceactually 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 orsomething.
But yeah his tweet was basically like I kind of feel like client siderouting 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 agreewith 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 someindication 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 tomake use of that information or something or notice something or whatever.
And then when we move to client side routing then pretty often what happensis 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 willhappen 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 rightaffordances 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 andstuff 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 doa full page refresh essentially is an entirely a bad one from that
perspective and then when you go to client side routing, you just reallyhave to think about those things.
So anyway, just some thoughts hopefully,

Further episodes of 3 Minutes with Kent

Further podcasts by Kent C. Dodds

Website of Kent C. Dodds