# Transcript: SvelteKit has solved data loading (Syntax #955)

- Transcript page: https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript
- Episode: https://syntax.fm/show/955/sveltekit-has-solved-data-loading
- Published: 2025-11-17
- Reuse: quote short excerpts, credit Syntax and link to the passage (https://syntax.fm/pages/terms-of-service#quoting-syntax)

> Scott and Wes break down SvelteKit’s new remote functions and why they finally solve the long-standing pain of page-level data in Svelte. They cover queries, forms, batching, caching, and all the clever RPC ergonomics that make Svelte’s approach feel surprisingly powerful and refreshingly simple.

[0:00](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-0) **Scott Tolinski:** Welcome to Syntax. Today we're talking about remote functions in RPC in Svelte. I'm going to say off the bat, this is the solution for RPC, for data loading, for anything. I don't want to use anything else on any other platform, and we're going to show you why. If I'm using React, it better look like this. So we're going to be breaking down what these things are, just the general approach for data loading, how it kind of takes the server client side of it all, and makes it really nice and palatable while keeping a nice separation still. My name is Scott Tolinski. I'm a developer from Denver, and with me as always is Wes Bos. What's up, Wes?

[0:43](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-43) **Wes Bos:** Hey, excited to talk about this because I dove into several of these like RPC libraries in the last couple weeks, you know, and it turns out BetterAuth has one called BetterCall. Hono has one. Eliza has one. Cloudflare has one that's called Cap, Cap'n Web or something like that, like it's Cap'n Crunch. And like, there are a lot of the, like this idea of like, obviously we talked about TRPC, we had them on the podcast as well in the past, but there's so many different implementations of this RPC, and I'm excited to see what Svelte's take on it is.

[1:22](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-82) **Scott Tolinski:** Yeah, this is something that I think we've both personally felt. The Syntax site is built with SvelteKit, it uses the load functions for data, and I think one of the things that always felt odd about that was like, all of your data, all of your, your refreshing, your invalidation, even your form actions, they all kind of live at that root of the route level, like on any given route. It exists on a page level. And like in a componentized world, that just felt weird, right? Sometimes you were defining actions on a route and then having to call them or refresh more data than you'd want or reinvest. Data load function. So I was really excited when they announced this at, Svelte Summit, and I've been doing quite a bit with this, like really quite a bit. In fact, Wes, you might be interested to know, I've been doing, going nuts on the, the new syntax website. So we've been working on a new syntax website.

[2:21](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-141) **Wes Bos:** Yeah.

[2:22](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-142) **Scott Tolinski:** I'm motoring, and it is like, I, I ripped out our ORM, so we're using Drizzle now. I changed from MySQL to, Postgres. I rewrote all of the data loading in Svelte remote functions.

[2:38](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-158) **Scott Tolinski:** I have done a shocking amount of things in that. And Courtney was like, is this, does this stress you out? Like, do you regret making these big choices? And I said, No, I love this. This is

[2:54](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-174) **Wes Bos:** what I love. I

[2:57](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-177) **Scott Tolinski:** love taking everything out of the cabinet and putting it all on the countertop and then like meticulously putting it back in and maybe 3D prints in boxes or something and that's what I'm doing right now. I just

[3:07](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-187) **Wes Bos:** like pushing the stuff to the back of the like we lived in our house for like three years now and I like got on up on a stool and we have this really deep cabinet and I was finding like hot sauce from like three or four years ago and like I should probably do a Tolinski on this right now.

[3:22](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-202) **Scott Tolinski:** I love taking it all out and then and the web dev is is absolutely the same. but you know at this point we I needed to like rework the entire data structure of the website anyway so it was like if I'm already reworking the entire schema and how the data's connected and like I might as well do it in technologies I actually like if it's easy enough to just migrate it. Yeah. Which it has been. Yeah. So it's been a it's been a trip but let's talk about remote functions cause I've been using These things like crazy. Basically, as of today, when we're recording this, this may change soonish, to get these things going, you do need to tick two different experimental options in a svelte config, remote functions true and async true. So these APIs are used in combination, the async svelte where you can just throw weight tags in your svelte components and just do that, and it just all works. Remote functions, though. Remote functions exist where you have a special file name. It's something dot remote dot ts or js. These can live straight up anywhere. And a dot remote file name is great because that lets you know off the jump, this is taking place on the server. You don't have to worry about client server, where's this code running, am I importing something like a database or something insecure in this. You know that it's a dot remote, it's a server-based file.

[4:49](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-289) **Scott Tolinski:** So that's really great, right? And then from within a normal Svelte component, you can just straight up import that query, mutation, whatever, we'll talk about those in a second, but you can just straight up import those as a function and call that function in your code. So if you want to, let's talk about the, like the first one of these, which is like querying data. In a dot remote function, you have a query, it's essentially like a query function that takes in another function as a parameter or like a schema that you can then use to validate your data. Either way, you have a function, that function can do database calls.

[5:32](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-332) **Scott Tolinski:** Returns data. In the client side, you're just calling that function, bingo, your data's there. You don't have to worry about, routes, you don't have to worry about paths, you don't have to worry about anything. It's like, I'm calling this function, and it's gonna go grab me my data. And it's very most simple, you could have a query function that just returns Scott, and then the client, you could say, get Scott, and then it just gives you Scott.

[5:57](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-357) **Wes Bos:** So, like, let me maybe explain to the listener if they're like, like, what's, what's the benefit of that? So.

[6:04](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-364) **Wes Bos:** Typically, when you have like a website, right, you have like a backend, you have a frontend, and then you need some way to communicate between those two, right? And you might make like a, like an API where you can like fetch endpoints, you might make like an open a, open API schema, so that you can, you can share types from the backend to the frontend. but with a lot of these, like RPC, like React Server Components, Svelte Remote Functions, the way that it works is you simply just import the function from your server. JavaScript and run it in your client JavaScript. And then there is a little bit of magic that happens between those two where you're not actually importing the client side code into, or sorry, the server code into your client. You're simply just importing something that will interface over the network if you're calling that from client to the server, or if it's server rendered, it's just going to run it all on the server. Is that a fair description of it?

[7:05](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-425) **Scott Tolinski:** A perfectly fair description of it. Now, when this gets really powerful is combining with the fact that you can just await anywhere inside of Svelte components. So you could just, even inside of a loop, you could do like an each await get Scott and then as the whatever. And the next thing you know, your data's just there. Or at the top level of a component, you can await in the top level of component and get that data there as well and utilize it just like you typically would. And you don't even have to await it either. You can just Run the query, and then you could also have a query.error, query.loading, or query.current, which then gets you access to the data when it's available. But if you want like server-side rendering and stuff, await it, and it just works. And if you want to see all of the errors in your application, you'll want to check out Sentry at sentry.io forward slash syntax. You don't want a production application out there that, well, you have no visibility into in case something is blowing up, and you might not even know it. So head on over to sentry.io forward slash syntax. Again, we've been using this tool for a long time, and it totally rules. All right.

[8:17](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-497) **Wes Bos:** This is, I won't say one place, but this is another spot that's felt has an up on React, because asynchronous components do not exist in The client-side React. They do exist on server-side React, and they have said that they're coming to client-side React, but if you want to simply await some data and then return the component, you can't do that on the client side, right? You have to have a user factor, you have to use TanStack Query, something like that, and you have to show a loading state. And that's a pain in the butt, because in many cases, you simply want to just return nothing while it is loading. And, and I think also this goes in hand in hand with the asynchronous component stuff, where I think the reason why Svelte and a lot of these places did not initially, offer the ability to do fetching at a component level was because you get this waterfall problem, where like you can, if you can fetch anywhere down the tree, then you can cause these waterfalls that can cause your render to be very, very slow. So React Suspense, Svelte, Async components, it solves that by allowing you to define, how long and what you should actually wait for if you're server rendering, and then what you should simply just send to the client and then let it load at a later point.

[9:33](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-573) **Scott Tolinski:** Yeah, there's a cool query.batch in here too, which I'll show you. So you can basically just await that data and, and get it. You know, This is really great because I found this to be super clean. I found it to be way nicer than having data in the load function. That load function then passes to props. You're kind of hot potatoing this. This is more like you have your function call already. You call that, you get your data, you output it, you can await it. You can also with async svelte, you can await inside of derived too. So if you want to have something reactive coming in from the server, you can just toss an await, get Scott inside of derived. That's super nice. So that's great. You can also pass in arguments. So these things are functions. You can pass in arguments. One really neat thing that they've done with all of the remote function stuff is that they've really leaned on standard schema. If you want to learn more about standard schema, we did a whole video on it. But basically, because it uses standard schema, that means that you can use any validation library out there to validate your inputs. So whether that's Zod, Valibot, Archetype, like whatever you want to use that uses standard schema, you can do so.

[10:45](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-645) **Scott Tolinski:** And inside of your query, if you want the, if you want to accept arguments here, the first parameter is just that validation. So in all of their docs, they use Valibot, which is really great, actually. I've been using Valibot. It's really nice. But if you could say like the query, the first parameter is a v dot string, then you know that that requires a string. And then of course you get all of your TypeScript, type checking, you get everything like really nice. I think that's one of the things that as you'll see throughout this episode is that the type checking story for all of this is so effortlessly good. And I think a large part of that comes down to their usage of standard schema, where you're not having to import types or whatever, and everything just kind of, whether it is client or server side, You have that type checking story the entire way, and it's really nice.

[11:38](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-698) **Scott Tolinski:** Yeah. Man,

[11:39](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-699) **Wes Bos:** the standard schema guys, like the Zod and Arctype and Valibot, they like all worked on that. And like, since we did the episode on that, I've seen it implemented in so many places, and it's become so much more important from like an AI perspective, because you can get a, quickly get a schema of what your data actually looks like. But then like when I run into stuff that doesn't use standard schema, like the Chrome, Chrome has like a beta right now for AI in the browser, and they use JSON schema. And it sucks, cause like I have to now, I'm like, I just wanna write it in, I wanna write it in Zod or whatever. Like for those who don't know, standard schema is this way that you can write your schema in Zod, Valibot, Arctype, Effect, whatever.

[12:29](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-749) **Wes Bos:** And then It will, there's a method on that will just convert it to a standard schema, and then you can also, many tools will also just consume a standard schema and convert it to, to whatever they need internally. And when a tool doesn't support standard schema, it's a pain in the butt now.

[12:46](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-766) **Scott Tolinski:** Yeah, cause now you gotta just use that tool. Where here it's like I can pick my own from all, I just pulled up a list of all the different ones, and there's so many. Effect schema, type map, form data, I haven't even heard of most of these. Joy, have heard of that, yup, have heard of that. So there's a whole bunch, and it's great that they are all kind of landing on standard schema, and even better that something like this would be like, you know what, let's embrace that, and because of that you can use whatever you want, which I love. There's also the ability to refresh your queries, like manually, if you want to refresh your queries at any given point, you just hake the query, and then you call a dot refresh method on it, and it will re-trigger that as a function. So that's nice. There's also query dot batch, which allows you to batch queries that happen within the same micro task. This is like, in their example, they basically had a list of cities, and then they had a query that was like get weather from that city. And the query was taking place inside of an each loop in the component. So inside of an each loop, the city had a await get weather passing the city that's being passed in from the loop. And so if you were to do this without the batching, you could imagine each loop is going to be a call, right? A remote call. And that's not great. So if you use query dot batch, it's going to batch all of them from the same task. And therefore it's going to not make a bunch of trips. Basically it calls them all instead of having multiple calls. Yes. So

[14:22](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-862) **Wes Bos:** the benefit here is that like instead of sending off ten requests for ten cities, it sends an array of ten requests once and then those ten things are executed on the server. And I guess you could have logic on your server to do them all at once or you can just fire them all off at once and then it sends all the responses back at once. So that helps both with network but also I'm assuming it helps with rendering as well because then you're not getting ten render updates as they come in, you simply just get one render once it's all done.

[14:53](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-893) **Scott Tolinski:** Yes, and in this particular example, they're able, because it's in that loop, they're doing query.batch, like you said, they're getting all of the cities as an array and it's one database call even instead of not just one API call, one database call. Yes.

[15:08](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-908) **Scott Tolinski:** Oh, that's

[15:08](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-908-2) **Wes Bos:** nice. And there's no fussing with like promise.all or anything like that. It simply just sticks them all in.

[15:15](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-915) **Scott Tolinski:** Yes. For this, for this use case, this, this rocks. Now let's talk about the, I think this to me is the, the killer feature of this all, because a lot of our PC systems have like a query system. You call the function, you get the data, right? There's a, another type of remote function called a form function, and the form function is the goat. This thing is awesome. So what's so cool about this is it's used for doing mutations, but not just general mutations. It's useful for doing mutations that take place on an HTML form. What this gets you is you're basically defining a form function using your standard schema stuff. You're passing in the inputs as the first parameter. The second parameter is an async function that does the work. But what's so awesome about this is not the server side stuff, because the server side thing functions exactly like you expect. Data comes in, you do the work, you return your stuff. But on the client side, the form function has a ton of stuff. So you spread the remote function onto a form, and then you get a progressively enhanced HTML form that works with or without JavaScript. You can spread out individual fields, and then you get individual field validation. So you write your standard schema on the server side that is then used to validate both the input into the function as well as the HTML input itself. Wait,

[16:50](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1010) **Wes Bos:** so it does, like, it will render out the client side HTML and the JavaScript that is necessary for it to client side validate?

[17:01](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1021) **Scott Tolinski:** Yes.

[17:02](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1022) **Wes Bos:** Oh, that, this is almost getting like, like, like a rails.

[17:06](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1026) **Scott Tolinski:** It's sick. It, this is sick because not only do you get that, right? So like the, the, the way you're spreading it out, you're spreading like, let's say it's a create post. You're spreading create post dot fields dot title as text on a normal input tag. That then sets the input tag to type of text. it sets the ID. It sets all of the stuff that you would need to have a valid working form input.

[17:33](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1053) **Scott Tolinski:** And that rules, man. I, I'll tell you what, I, I, I, was working on A blog. And I use this in, like I'm doing a tutorial course on, which is, it's gonna be out by the time you are watching this, so check it out on Syntax if you wanna learn how to do this. But like, man, to be able to build this, wrapping a label around an input and just saying here, use that, oh it's read only, like man, this kicked ass. And I really, really liked working in this way. But it gets even better than that, because not only do you get those things, man, you get, so you get the validation component and stuff like that, but you can also get error messages, you can get, sorry, I'm scrolling through the docs. Stop

[18:23](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1103) **Wes Bos:** me. A couple episodes ago, you were fighting me and saying, I was, I was showing you some form library that like, that did this.

[18:33](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1113) **Scott Tolinski:** Yes.

[18:34](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1114) **Wes Bos:** And you're like, I don't need that. I could just do that with this felt store and a couple of lines of code.

[18:39](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1119) **Scott Tolinski:** Yeah, that's on Joomla. Now you're here,

[18:41](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1121) **Wes Bos:** you're, you're gushing over the, exactly this.

[18:44](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1124) **Scott Tolinski:** No, this is, this is the platform.

[18:47](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1127) **Scott Tolinski:** Mind you, this existed when we, this existed when we recorded that episode. This is less code than that was, too, I'll tell you that. My point was is that if I want, not that I don't want a form library, it's that if I have a form library, I want it to do more for me. I don't want it to write all of the inputs, I don't want to have to write the update stuff, I don't want to have to write any of that stuff, because at some point it's like, what is the library doing for me? I want the library, or in this case, the platform to do more for

[19:19](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1159) **Wes Bos:** the forms. I want it to pass it into giant objects. Exactly.

[19:38](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1178) **Scott Tolinski:** Yeah, and like I do want to push back on that, because I, I, I agree, like, I do think form libraries are really nice. I've built my own so many times, but I want the form library to do more. If I'm having to write out every little bit, yes, then at that point, like what that library did, I didn't see a benefit of it.

[19:58](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1198) **Scott Tolinski:** Like yes, it handled validation in those types of states, but you still had to write most of that code yourself. And a lot of that was because of how you work in forms and React in general. So that's my point. Also, this gives you client server, gives you the whole bingo bango, gives you everything here. There's also, you can do programmatic validation with it easily enough. If something becomes invalid, you can get the error message directly from here without having to write any of that. You don't have to have controlled inputs or anything like that. The state just kind of lives as a part of this remote function. So you don't have a controlled form. You don't have to deal with form data on yourself.

[20:40](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1240) **Scott Tolinski:** You're just writing an HTML form that works. In JavaScript or without JavaScript, and you get access to things like the individual error messages if something becomes invalidated.

[20:52](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1252) **Scott Tolinski:** It's pretty sick.

[20:53](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1253) **Wes Bos:** That's great. I could see myself building even like a even higher level wrapper on this. I'm already doing that, yes. At a very high level, just took all my inputs, figured out what kind of input they needed to be, you know, is it text area, is it a number, is it a date, et cetera.

[21:08](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1268) **Scott Tolinski:** I love doing that. I'm already doing that, yes.

[21:11](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1271) **Scott Tolinski:** Huge, huge fan of that. Yeah, it's really neat. And like, obviously, if you want to step in, and there's this whole progressive enhancement story, if you want to step in and do more with JavaScript in here, you can do a dot enhance on here and get access to the entire process. So let's say you want to throw a toast message after you submit it, or you want to handle errors your own way, or you just want to step in there, you can hook in, you can call a wait submit, you can call a form dot reset if you want to, and you can step in there.

[21:45](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1305) **Wes Bos:** If you need to do something custom on like key up or something, you can overwrite the default one.

[21:50](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1310) **Scott Tolinski:** Totally. You can also get in here and do, you can update the state programmatically of the form. Keep in mind, again, these aren't like controlled forms in that way, but you can get on here in an individual field by referencing mutation dot fields dot the field name, so dot title dot set, and you can programmatically update that, and you can grab the value at any point with fields dot value and get access to that value live. So it ends up becoming a controlled input, but you didn't write one line of state. You didn't write a state updater. That state just lives with the form, and it all, it's, it's just so cool.

[22:30](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1350) **Scott Tolinski:** love all of that. When you're done with these, you can update your data, so there is the dot refresh, method that we called before. If you run dot refresh, it is just running that query again. But there's also a dot set method, too, on that. So let's say your mutation returns the new data, right? Like you did an update, and that mutation actually returned the new data. You wouldn't have to then call a refresh and have it do another database query. You could use this dot set to take that new data and just insert it as the result into that query and pass that along, avoiding an extra database call. They really thought of, like, everything here.

[23:08](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1388) **Scott Tolinski:** there's even optimistic UI you can do with this. So it's pretty sick. Form is goaded. It's, it's awesome. There's so much here. There's also a command query, so this lives in a remote function. This is basically just a mutation, function.

[23:23](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1403) **Scott Tolinski:** That you would exist where you're not using an HTML form. But the form one makes it so easy. It's like, we should really be using forms for so much more, right? Like just wrap a form in a button. Yeah.

[23:36](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1416) **Scott Tolinski:** So everything should be

[23:37](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1417) **Wes Bos:** like there's the best way to transport data from the client to the server is with form data, right? Like form data is the best. You can have multiples of the same type. You can have images in there. You can have multi-part. It's just like all the remix stuff is all built on form data as well. It's just one of those standards where everything going forward should be built on form data. And an added benefit is that you can simply use HTML forms if you want.

[24:04](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1444) **Scott Tolinski:** Yes. and also, like, in, in addition to that, something we do a lot on the Syntax site, URL as the state using, query parameters. State in query parameters on the URL. Yes, it's shareable. It, it's very nice. I think those two things are totally underrated. forms, query parameters.

[24:25](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1465) **Scott Tolinski:** the last one here is pre-render. Pre-render is basically query, but it's something that only runs on build time. So if you're doing static sites, you only wanted this to ever run on build, you have the option to have the pre-render. So that's it. You have query, query batch, form, command, and pre-render. those are the different remote functions. They all kind of have a specific use case.

[24:49](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1489) **Scott Tolinski:** And man, I've been, I've been ripping on this stuff, especially on the new syntax site, just like whether or not it is just throwing a database query in here or there or whatever, or changing our remote functions. I, I've just been really, really, as I get through with this, I'm writing less code, I'm getting better validation, the TypeScript stuff is so nice, I'm not having to import types and anything like that, all type safe across the board.

[25:17](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1517) **Scott Tolinski:** It rules.

[25:18](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1518) **Scott Tolinski:** very big fan of this. So, that, that's pretty much it. Do you have any, have anything there? I do have one last thing. I have a question about,

[25:23](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1523) **Wes Bos:** is there anything related to caching in all of this?

[25:28](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1528) **Scott Tolinski:** Yeah, so, caching, especially like, You would, it would still happen at like, if you're, especially if you're doing server side rendering, right, that's still happening at the, like the page boundary, right? If you're caching that, it's still happening at the page boundary. I think there's going to be more with the caching of the data. There's some caching stuff with the pre-render queries using the cache API, but in general on these functions, you're not setting cache headers.

[25:55](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1555) **Wes Bos:** So this is something that only Next.js I think has nailed. Yeah. And it's the ability to do a component level cache. And a lot of people don't understand. So let me, let me give an example. On my website, westbos.com, I have the syntax, latest syntax podcast in the footer. And that is a syntax component in the footer of my website. And that does a fetch. To the syntax API and then brings it back. And there's a problem where, and I have a couple of other things in the footer of every page, right? And I can, I cache the data there, right? But I kind of want to just cache the entire component as it's being rendered. And there's nobody except for Next.js that has the ability to cache a component level. Everybody's caching entire pages, which is sometimes okay, but like, but what I end up with sometimes is that like, if I cache an entire page, then the footer data is sometimes different from page to page because they've been cached at different points. So

[27:02](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1622) **Scott Tolinski:** the

[27:02](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1622-2) **Wes Bos:** other, the other option is you can simply just cache the expensive stuff, which is the data fetching and then just re-render every single time or set like a really short re-render on it. But I'm, I'm curious to see, and I bet Svelte will roll out something like this as well, where you'll be able to just say, cache this entire component for however long, and then do the whole stale wall revalidate headers on it, and that would be sick, because then you can reuse that component anywhere else on your dynamic site, but you don't have to spend the overhead of re-rendering that sucker and doing data fetching.

[27:36](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1656) **Scott Tolinski:** Well, let me tell you, Wes, I also felt this pain. I felt this pain, and that's why I took it upon myself to make something. which, so I wrote, and I'll, I'll show, I'll share this with everybody, and this is, I'll, I'll say this, it's naive, it's a quick implementation, but it works really well. What this is, is a service worker, because service workers are built into SvelteKit, it's a service worker that basically does stale wall revalidate using index DB, so it takes any, right now it's just queries, it takes any Remote function query because I can identify those. It takes any remote function query and saves it to index DB. On the next page load, if it's being done on the client side, it's going to check index DB and just load that data. So it's basically like a local index DB cache that I don't even have to do anything in my code because it's a service worker. It's just there. It worked really well. I like wrote this and like I'm not good with service workers and I, it's a pretty small implementation, 150 lines. I do need version numbering needed. I chatted with CJ about this yesterday.

[28:54](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1734) **Scott Tolinski:** But Man, it works really stinking good, man. You're doing like massive amounts of data loading within, you know, 10 milliseconds because it's just there. It is like, it's like the, not local first, but it's the local data cache lessons I learned from using something like Xero just tossed into an automatic service worker.

[29:14](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1754) **Wes Bos:** That's great.

[29:15](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1755) **Scott Tolinski:** Yeah, I was pretty stoked about this working well. That's

[29:17](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1757) **Wes Bos:** similar to what I did on my side as well, but I did this on the server. So I stuck everything in like a key value store and then I, as part of my data fetching strategy, I just first checked if it was there.

[29:30](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1770) **Wes Bos:** But that doesn't help the fact that The, the actual component itself has to re-render in the demo. Well, sure.

[29:36](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1776) **Scott Tolinski:** Yeah, yeah.

[29:37](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1777) **Wes Bos:** If you, like, if you want to, like, server render and cache an entire page and then go from page to page, then you're, you're in trouble. That's a hard problem. I don't envy anyone that has to work on this caching stuff, because it's, it's a can of worms, and its edge case is all the way down. It kind of sucks to have to work on that. Cache

[29:55](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1795) **Scott Tolinski:** and DNS and what are all the things. Yeah, those are.

[29:58](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1798) **Wes Bos:** Cache ruins everything around. We got to make that shirt.

[30:01](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1801) **Wes Bos:** I have a rule, no funny shirts, but man, that would be a good funny shirt.

[30:06](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1806) **Scott Tolinski:** Yes. I mean, Wu-Tang is for the children, so I think, I think it qualifies.

[30:12](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1812) **Wes Bos:** Beautiful. Well, I'm excited to see all this implemented in the new syntax site because this was one of the biggest qualms I had with Svelte and they have done a fantastic job at solving that.

[30:23](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1823) **Scott Tolinski:** Yeah. Yeah, I, I, I, it was one of those ones that after it was announced, I, I, I had so much on my plate that I didn't dive into it. And since diving into it, just big, big fan of this implementation. I'm not, I'll, I'll say this. I'm not saying no other RPC systems have, have done it as good as this, but it better be as good as this if, if you want me to use it. Cause now I've, I've been the edge and back and I, I very, very, yeah.

[30:49](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1849) **Wes Bos:** Yeah, I don't, I don't think you would get better than this, because it's like, it's tip to tail, right? Spelt kit has control over absolutely everything.

[30:58](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1858) **Wes Bos:** for something where you just need to add RPC into an existing solution, that's where you probably would reach for one of these, you know, individual one. But man, is it nice having a meta framework where it just is, is tip to tail. Yes.

[31:13](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1873) **Scott Tolinski:** Snout to,

[31:16](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1876) **Wes Bos:** snout to hoof?

[31:17](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1877) **Scott Tolinski:** Snout to hoof. That's not that far of a distance if you think about it. No. No.

[31:23](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1883) **Scott Tolinski:** cool. Do you want to get into sick pics and shameless plugs?

[31:27](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1887) **Wes Bos:** Yes. All right, I'm gonna sick pick my dishwasher. I talked about it in the last couple episodes. I'm very happy with it, but I, we've had it for like almost a month now, and we got the Bosch 800 series dishwasher, and this thing is amazing. It's got the third row for, I don't understand how they, they have more room in a dishwasher when it fits into the same physical one, like the 24 inch thing in your, in your kitchen, but this thing is awesome. So if you're looking for a new dishwasher, and you're tired of fussing with them, you know, like we have, we have a house, we have a cottage, we had our old house, like I have fixed enough dishwashers in my day that I know do not buy the $500 LG. LG does make good ones. they're, they're higher up there, but man, it's, it's a nice life improvement if you can get a nice dishwasher.

[32:18](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1938) **Wes Bos:** So our old one lasted for 21 years, and we pulled it out, we're like, yeah, we'll just buy another one of those. So, sick pick.

[32:27](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-1947) **Scott Tolinski:** Nice. I'm gonna sick pick my new cold brew setup. Man, I've been, I've been making my own cold brew for a while. And when you make cold brew, like, there's a number of things that can go wrong. It can get really, bitter really quick, and can get really, like, burnt tasting. And I, like, went deep on, like, what am I doing wrong? Because I was just kind of suffering through mediocre coffee when I, like, it's like I, I drink good cold brew other places. I know it's possible. Like, why can't I, dial this in? So I dialed it in. I am now measuring my beans. I'm doing, seven ounces of, of beans per coffee sock. So the sick pick one part is going to be a coffee sock. it's basically just like a, a cotton sock that you put the beans in. And I do that in a, this is a 64 ounce, mason jar.

[33:20](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-2000) **Scott Tolinski:** You can buy a kit that comes, I'll have a link to this.

[33:24](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-2004) **Scott Tolinski:** You can buy a kit that comes with the mason jar and the coffee sock.

[33:27](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-2007) **Scott Tolinski:** Now the key to this all is you brew it either in the fridge or on the counter for like 24 hours, right? You do the six to eight ounces, you put it in the coffee sock, you fill it with water, but the key ends up being a double filter. So after you're done with that, I then have another glass thing and I pour through one of those Chemex filters. I don't have like a fancy setup, but the Chemex filters are these paper filters. And you double filter it through the paper filter and then I do that into like a giant glass pitcher. And man, it tastes like Starbucks cold brew. It tastes like the stuff that I buy in the store. It is perfect. It solves every issue that I've ever had with cold brew. The two things that are important is like the double filtering is a massive one and then the amount of time that I'm brewing plus the amount of beans. But let me tell you, it's been really great. And now it's so much more economic. We have like, economic, economical, I don't know. Either way, we buy a big old thing of beans from Costco, you ground them up, you put them in the thing overnight, and then, a big thing that was important to me was that it had to be all glass on glass, the whole process, because so many of the options out there are like plastic filters or plastic brewing systems.

[34:45](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-2085) **Scott Tolinski:** There's one cold brew like system that's like a countertop machine that is really just concentrated cold brew pods that it's mixing with water. It's like, what's the point of that?

[34:56](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-2096) **Wes Bos:** Who's buying that?

[34:58](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-2098) **Scott Tolinski:** They're expensive too. It's like, what's the point? so, yeah.

[35:02](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-2102) **Wes Bos:** Man, we, I, I, for the longest time I wanted an espresso.

[35:06](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-2106) **Wes Bos:** And I finally, I finally got one. Those things suck. Well, like, it's, yeah, like it brews okay coffee, but like it's like four bucks a pod, and you gotta buy the special ones, and there's DRM in it, and like, no thanks.

[35:22](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-2122) **Scott Tolinski:** You know?

[35:23](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-2123) **Wes Bos:** Like, beans are not that expensive, and if you can just figure out how not to be an idiot, and do a little bit of research, like Scott just did, you can make some wicked coffee at home without being like an obnoxious coffee person.

[35:36](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-2136) **Scott Tolinski:** Big old bag of beans, doesn't matter what, because cold brew especially doesn't matter. Normal beans, like, but yeah, I get whatever is on sale at Costco that's decent, crunch it up, and then I do two 64 ounce ones, because we consume a lot.

[35:53](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-2153) **Scott Tolinski:** And then I put it into a big glass thing, and it's glass on glass on glass the entire way down, glass, cotton, paper, that's it. So,

[36:01](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-2161) **Wes Bos:** done.

[36:03](https://syntax.fm/show/955/sveltekit-has-solved-data-loading/transcript#t-2163) **Wes Bos:** All right, thanks everybody for tuning in, we'll catch you later.
