Skip to main content
View on YouTube to comment and like!

Syntax Video

React Server Components, Worth Your Time?

Chapter 1 0:00

Welcome

welcome to syntax this is the react server components show react server comp components have been sort of cooking for I don't know what was it December 2020 when they were first announced um and here we are January 2024 so however many years that is uh I feel like we are finally at a spot where we know what they are we can there's people using them in production and we're at a spot now where react devs are going to say okay what are these how do I use them what are the benefits what are the gotas the design patterns because it's it's a fairly substantial upgrade to react um and we're going to we're talk all about the the pieces and how it works together but let's talk about Sentry you have a react application and you are goofing some code up like I tend to do in your react application you're going to need some error exception performance

Chapter 2 0:48

Syntax Brought to you by Sentry

tracking uh session re replay telling you and helping you figure out what went wrong where how all that good stuff so Sentry is fantastic for that check it out sentry.io use coupon code tasty treat for two months for free sick how you doing today Scott oh hey man doing I'm doing just about as good as one person can do uh to to give some context we're recording this on January 9th uh yesterday was Monday January 8th AKA uh Miss won the national championship in football which uh means nothing to Wes as being one not from the United States and two not caring about sports especially American football but for me I uh you know many people like you know they they make University of Michigan football their entire personality that was not me I went to school at at that school and never went to a single football game so it wasn't until after I graduated that I got

Chapter 3 1:18

New Heights with Scott and Wes

really into Michigan football and you know what man they've been absolute uh dog [ __ ] since I went to school there in fact like my freshman year was maybe the last year they were decent and um I've been waiting this long for them to be good again and they had an undefeated season they did not lose a single game and then they won the National Championship uh they they beat all the the you know they beat Alabama they beat um Ohio State all of our big rivals and stuff and college football man a lot of teams and uh yeah it was absolutely wild and uh my my wife and I were just screaming our brains out last night so uh I'm doing great today I'm having a lot of fun congratulations that's that's good and I like Michigan big fan I've been there many many times and I'm happy to hear that the football team did did well I'm I'm I'm still blown away that

the American like college football is so wild like that like like I went to University and like we had a hockey team and I went to one of their their things and there's like 11 people there oh you know like like you you grew up like watching like this is what university and and college is like and you have these campuses you walk around and there's these huge football games and like it's nothing nothing like that in Canada uh so I would like to go to even like high school football down in the south is is pretty big too isn't it yeah it's it's it's very popular but Michigan uh specifically the the big house where the Michigan football team plays is like the largest stadium in the country I mean it's that big it's massive so like going to a football game there which I have been to by the way I didn't go to any when I was at school they're they're just it's insane it's it's very loud it's very intense and like people go nuts for it so I would like to do the Buffalo Bills tailgating experience at

some point in my life that seems super fun yeah my uh my realator has uh like at the Broncos stadium he has like 10th roow tickets you're like basically with the players and so he takes his clients to games so I got to go to a game and we did this whole pregame VIP thing cuz he's you know fancy and we're back we're we're getting all free food and hanging out with past players and stuff like that it was pretty cool love it all right let's talk about react server components um and what they are how they work all of that good stuff so first of all react server components are a totally new par Paradigm um in react meaning that react of course you were able to render react on the server in the past but that you generally had it to sort of like lean on a framework for that kind of thing the react is sort of becoming a little bit more opinionated whereas you used to have to like lean on

Chapter 4 4:23

What are React Server Components?

like a remix or nextjs for these types of things you probably still will for a framework but a lot of the how things are server rendered how they fetch data how they are loaded how they are sent from the server to the browser those things are being done opinionated and that is really cool because it means that we're going to be able to have react components that work across any react application yeah I think the coolest thing is that it it's going to establish patterns for things that uh a lot of people are needing to do right now but it adds that I think the the big thing for for folks who are scared of it it adds that additional layer of complexity you're not running this on the client exclusively anymore and once you add that server layer into the picture I think it could get people scared but you know for me I haven't built a web app without a server

connected essentially in a in a while so for me like I may be a little less intimidated by the fact that hey there's this this server now that has to be a part of your workflow Beyond just hitting an API right yeah I so a lot of people are there's a lot of opinions flying we'll get into to some of those in a bit but honestly so I took my entire website which is a a Gatsby react based website and I converted um the layout the header the footer and a couple pages so not the whole thing it's a it's a pretty big website with many thousands of pages but um just to sort of like get a feel for it and then I also built a couple little smaller applications just um by themselves so I could test out a few things and I was surprised at how much like two things a yes you have there's a lot more thinking that goes into a lot more paradigms and that it's certainly a lot more tricky but B the amount of code

that I had to delete a all lots of custom hooks um lots of like a API endpoints um serverless functions they certain I just deleted a lot of them because I was able to just bring that logic into a server component so what is a server component a server component is a component a react component that is here we go rendered on the server meaning that it is not rendered on the client um all of the data fetching that's probably the biggest one all of the looping templating everything that need to happen happens on the server and react simply sends I'll explain what it is in just a second but essentially react sends HTML from the the server to the client and it's just rendered out on the thing so why why would you ever want to do that first of all server components are asynchronous meaning we've never had asynchronous components in react before

and what that means is you are able to Simply await a fetch before you return your jsx and it's it's beautiful because you simply say like let's say we wanted to list the syntax podcasts uh const shows equals await fetch the syntax API and then immediately beneath that we Loop over each of the shows and render out the title and the description and all that stuff that's associated with it and that is amazing because it takes care of like you don't need a hook that is initially undefined and then when the data fetches updates and it renders a component you don't need that anymore right there's no custom hook in there there's no loading State because you're simply just waiting for the thing to be fetched before you go ahead so you can take out a lot of your loading States um there's no API endpoints needed in a lot of cases because it's rendered on the server you can literally and this is the

same thing with a lot of these meta Frameworks you can just query your database directly in a function so so you don't need to make a rest API you don't need a graphql API you can straight up SQL statement drizzle Prisma SQ light whatever you're you're fetching your data or whatever you're doing servers side to get your data that needs to happen servers side it it's simply just just done and you don't you can import all your server side packages right into your react component which is really really nice and that's the one thing when we built our spelt site where I was just like oh this is really nice you know yeah you know what it's so funny to me because like I came from meteor world as I've mentioned a hundred times on this show and like that's how you did stuff in meteor so there there were I I didn't encounter a loading State until I started moving my code base off of meteor and that was always like weird for me it's like I have to now worry

about a a status of this application where there's no data here yeah like if I'm using the data why do I got to worry about waiting for that data so for me that was always like that was like a major sticking point so it's interesting to hear now that the sticking point for people is moving from that you know I had to worry about loading States or in a status where there was no data to now worrying about a situation where you're getting the data directly from the database and also you know you know people dunking on like the database queries directly in your components that's that's wild to me that's what I've always wanted I want that I want that connection right cuz hey your your component needs the data like it feels like that's the perfect place to load the data to me and I I think a lot of that initial to somebody seeing a button with an inline SQL query on uh inside of it people didn't people didn't realize that there is a difference between

Chapter 5 10:35

The difference between server components and client components

server components and client components they are always always always always separate files um you can you can put your your database logic in a separate file uh and import that function into it and you can mark it as we'll talk about it a use server mark it as a server function it will only ever run it on the server so you don't have to worry about like it it's not running on the client obviously right um but I think I think a lot of people had a quick knee-jerk reaction to that type of stuff why why would you want to run something client or sorry server side um large dependenc these do not need to be loaded on the client if you need a big package to uh to do something on the client you don't need to load in a Meg of JavaScript you can just use that server side where it's already loaded and simply just send the eight divs as a result to the actual server so it's

Chapter 6 11:22

Why would you want to run something server side?

going to be much smaller you don't have to find a client friendly version of something and make sure it works in all the browsers as long as the markup can be sent to the server then you're in good shape and same thing with like file system API so I did a bunch of examples where I was literally reading how many files I had in the file system and then putting that into a button um in a client component we'll talk about that in just a second it's it's pretty cool to be able to just say all right this one is only serers side and I can use all of the serers side apis that I could ever imagine or ever want yeah it feels really positive to me I know I don't know to say that yeah well we haven't got to the rest yet so hold you might you [Music] might you might you might change your mind I'm I'm I I was I'll say I know I told myself I would hold back on opinions but um there's a lot of like

initial ah really that's the best way and um I think that will change but I'm not sure and there's there's a lot just asking on Twitter there's a lot of people who are like uh but I think it's going to be okay we'll talk about those in a second so let's talk about server components we just talked about server versus client components so client components are components that have state components that have custom use effects um components that have event handlers on click on submit all of that good stuff um and the weird thing about this is that client components are still server rendered initially however they are rehydrated on the client much like you would expect on a traditional like rehydrated uh server side rendered and then rehydrate on the the browser approach like that's what we've been doing a long time the the big difference here is that not everything is a client

component like it previously was and in fact you have to sort of opt in to client components in react when you do need to do the things that we just mentioned when you do need custom State effects event and event handlers and anything else that like you're accessing the window object or something like that that's when you would reach for a client component initially I was like you can't put state in a server component yeah like doesn't that initially that sounds awful but you know you know what's just as good as State on the server variables data yeah data yeah you're right variables as state you don't need custom State on the server side because you simply just await it it's a so you simply just await the fetch request and then you you have the thing and that that state never updates because it's server rendered you can render the server components I'll talk about that in a sec as well but again if you need to render it then you simply

just rerun that fetch request and then it will return the whole component and you know who's going to be particularly Adept at picking up those Concepts anybody who's used Astro or anybody who's done like just straight up JavaScript on the client hey you know if you're if you're writing you don't write your interactive um JavaScript to interact with things and make them interactive on the server that makes no sense right uh why why would the server care about you know events for a slideshow they doesn't care at all right that's exactly my next point is I'll say the first point here is that components are server rendered by default so when you are building a react application by default everything is server rendered um and then you opt in to client side components when you need interactivity and uh updating state so if if you think about the way that we

Chapter 7 14:49

Components are server rendered by default

used to do it a PHP backend and you add a little bit of jQuery on top to make that part interactive um react islands is another example that is very popular where you have a existing monolith application and then part of your application is built in react because that is the piece that needs to be interactive right or JS sprinkles um lots of different Frameworks out there where you server render the whole thing and then you use a JS sprinkles library to make the parts that you need interactive and if you think about react client components in the same way you say okay I understand this whole website is server rendered but now I want to make these parts interactive have click handlers have custom State drag and drop then you opt in to being a client component and and just for the audience um when Wes says things like JS sprinkles he's not referring to a

Chapter 8 16:03

What is JS sprinkles?

library called JS sprinkles he's referring to sprinkling in actual JavaScript as needed not like uh not like some kind of actual technique or whatever he he's just he just likes sprinkles yeah uh Alpine JS is probably the big one uh in the space there you go back and listen to episode 568 with Caleb porio he's the author behind Alpine JS and he explains um that whole idea of JavaScript sprinkles which is if you've been around since J days it's really not all that complicated um it's just a bit more declarative when you use Alpine JS kind of like angular one if you anyone remembers that as well yeah if anybody remembers angular one for sure how server components work the server will render the component and send the react code over the wire um and you can essentially think of that as the react server will render it's not HTML but if

Chapter 9 17:22

How do server components work?

you think about it as HTML like for example if you had a list of podcasts from syntax and you wanted to server render it because you want it to format them in a certain way and it's much faster to do it on the server um you can think of react is just sending the div HTML and then the react on the client side will say oh I got some I got some HTML from the server let me just put that into that part of the website where it belongs and what it's actually sending is a react component with references and all of the data in it there's a really nice Chrome extension that you can see the pieces being streamed in from the server to the client and when I saw that I was like okay this makes a lot of sense of how it's working but if you kind of imagine it as just hunks of HTML are being and that's how htx works you just send hunks of HTML to update part of the website yeah and I love that you know what it's one of those things that I

think makes so much sense if if you think about it in terms of how we work on the web I don't know why it works any differently all right so now comes the tricky bits and this is the the where the tears sort of come when people are trying to move an existing application because if you have a medium to large size react application I would even say small small medium to large uh and you want to move it to server components you're in for for a couple hard days uh because how many hard days would you say um depends on the size obviously like to give you to give you an idea uh being after building two small applications I took my website which is not just a list of links that gets 100 on Lighthouse score there's many thousands of pages there's guides on there there's there's tips there's blog

Chapter 10 18:43

Moving an existing site to React server components take a while

posts there's a whole store built into it there's quite a bit of stuff on that that website so I built the the nav the footer the layout um I poured it over the style of components because that's what my styles were were built in and that probably took me three and a half hours and I bet if I were to Port over the rest of the website I would probably need another like 15 20 hours which is is fairly significant for it's not a large application if you have a application with lots more interactivity my site is primarily content based um if you got a lot more interactivity then you're you're going to be doing a whole lot more and the reason behind that is because like I said server components by default and the rules of putting server components inside of client comp components and vice versa are a little

Chapter 11 20:17

The rules

bit tricky so server components like think of generally you can think of your page as a server component and then as you get into smaller pieces of your website those are all server components until you get to one where you say oh that needs interactivity this has buttons this has uh drag and drop this has a map in it so server components can have client components um however client components cannot have server components and that's where the red react errors start being thrown because you start you say oh yeah let me just let me just take that server component of the latest episodes and let me let me throw it into this thing that is a client component and then it says you can't do that um because client components and server components are separate things I have a good metaphor for this Wes yeah or do you want to do your no go for it please

please go yeah if you think about it like you if you think about it like a tree which is often how we think about react applications in general right you have leaves and all those things right um you could think of client components as like the foliage of a tree and any of the server components as like wood or or branches and Trunks right you can't go from Leaf to trunk but you can go from trunk to or Branch to Leaf right you can't go from Leaf to Branch Branch to leaf and you're your server components are kind of inherently uh I don't want to say thicker harder they they're they're more there's more infrastructure there I guess you could say they're thicker components we got uh server components are thick components um but uh yeah you can't go from Leaf to Branch I guess is ultimately what I'm trying to say and that makes perfect sense to me it it makes sense but in practice you run into this issue a lot in in my experience

really and so there is a way to make it work and I'll explain that in just a second but like let's imagine uh you have a cart um and you can drag items into your cart right so you've got a bunch of products and a cart you drag a something from the uh products into your cart so your cart obviously has to be a client component because it needs to handle drag and drop and clicks and and deletes and all of that stuff right however if you want to calculate the total of the user's cart that's probably better as a server component because there's a lot of logic that goes into how much shipping costs any coupons that they may have um if there generate that that that total value on the server though as data you know yes well that's that's the fix but what what somebody will do is they'll say okay well I'll make a server component called total

value that's a server compon component and I'll just try drop that inside of my cart component which is client and then it can't do it um so the fix to it is that and I think that this is just like a a DX issue with jsx in general is that client components can have server components passed in as children or as props so you can't put a server component in a client component file but you can wrap jeez can you can be in a server component you can have a client component and then wrap that client component around another server component or pass it in Via props and you're prob I'm probably losing you right now go to the show notes and click the tweet that I have I I made a whole visualization for how it actually works um and that's sort of the way to go around it but you can't like if you're used to just going into a file called

cart. JS and putting in a component you have to now pass that in Via props in order to to make it work it's kind of frustrating to do that and I think it's more of a having to understand and getting new design patterns in place to make it work but I think a lot of devs are not used to this type of work H yeah that's wild I I yeah I'm surprised how did you discover that yourself or did you see somebody talk because that's a an interesting like I don't know if I would have like instantly said hey can I pass this as a prop here yeah because like like literally any other framework I've ever worked in in all of my web Development Career if you have a partial or a component or a spelt or whatever you can just import the sucker and put it in and and you're off and running but now you really have to think about this and it's it's it is I think it is a bit of a foot gun because you think oh yeah

and the other thing is that the way to fix a lot of these red errors is you just Mark something as a client component so you to Mark something as a client component you write use client at the top of the file and that makes that file a client you cannot put a client component and a server component in the same file which is another frustrating thing that you have to have multiple files yeah if you're trying to do like for an example would be with that cart um if you wanted to put that button in there you would have to have two or three files mhm just to render out the cart and doesn't burn me that much I complained about this enough with spelt I'm like just let me put them in the same component well Wes you'll be happy to know that spel 5 fixes that I've been using spel 5 has a new way to do you can do uh multiple components per file now and so I have been doing that a lot and it is nice but you know that Ed client thing is interesting to me because you know one of the big arguments about react is that it is just JavaScript is use

client like any sort of JavaScript standard or is that are we like now pass the point where react is just JavaScript react is that's a good question because because like it's it's a jsx thing it's not a jsx thing no it's not it's a react thing it's a react thing and it's a way to uh provide metadata to the file and yeah I think that's okay the used client is not a a standard we have you strict that is that's what I'm saying it's fine you know but you know like people like Astro have been doing this with their like markdown at the top of single file components or remix whoever um yeah it's not just JavaScript that that argument always kind of bugged me anyways but let's talk about forums because likely a lot of the use case where you have to do the afrom mentioned dancing between server and client components is with

Chapter 12 27:09

Form Actions + Server Actions

forms because forms need inputs from your user you often want to do client things with your forms like validation when somebody types in something you want to reformat it credit card input Etc and then you always need that all of the data from that form on the client side and it's long being a pain in the butt of dealing with forms in react you've always had to reach for some sort of thirdparty library or roll your own custom State hook and never been a big fan of that so part of server components they have rolled out um this thing called uh server actions and form form actions and server actions so form actions are so like react is now becoming opinionated about the way that you work with and submit forms uh to the server which is thank goodness like I'm so happy about this because we can now F

you don't have to fuss with it uh anymore and it is using the standard form data API which is a JavaScript standard for describing and parsing form data into a JavaScript object and being able to send that to the server so form actions are functions that run when your form is submitted and you pass a function to the action prop on a form so in HTML you have an action that is a string and that string is a URL of where the form is submitted to um in react the form the action property is reference to a function that will run when somebody submits that form so and then that function itself will give you the entire form data object so you simply just write a regular JavaScript function handle form submit the first argument of that function is the form

data and then when that uh when that form is submitted you have access to the entire form data API and that can happen on the client side happens on the client Side by default and uh spelt users will recognize this this is kind of how forms work in spelt uh kit um you get access to the farm data as a prop or uh I got to say as somebody who's been doing a a similar workflow I love this um this is how I prefer to work so um props on react for doing this and honestly you know react has long been non opinionated on these types of things and it's the reason why we have things like remix and Astro and I'm happy to see that react is making um choices there exactly uh now those form actions run on the client by default I said however if you mark them with a used server in the function now that function will only be run on the

server so again this is another little bit of a confusing thing it's one of those things it makes sense if you think about it and there probably was lots of discussion about it but the initial reaction to this is so you're telling me components are server by default and client you have to opt into client side with used client however form actions are client by default and you have to opt into server when you want them to run on the server and that might make no sense but if you think about it forms are going to be client side if you want to to do any of your interaction so marking it with a use server um makes sure that that function will only only ever run on server does it do a full page reload or is it do do it Progressive enhancement like so that's what happens is if you mark it with a used server it will then submit the form data to the server it doesn't do a page reload or anything it simply just

submits the data to the server um and then you can then return data from the server or you can return an entire component um that needs to be rendered on the page and it's actually really really simple I I like this a lot where you can simply take a client side variable call the the function from the client and that variable will be available to you on the server side which is just like not mind-blowing because we certainly have had things like that but uh be that like seamless transition of passing a variable from the client side to the server side without having to do any API No Rest API no Json stringify none of that it's just man I'm I'm in love I absolutely love it yeah love that buttons can have actions as well so this is one thing I I thought was kind of weird and spelt is we have like a button

Chapter 13 32:07

Buttons can have actions

that says like fetch transcript um and I always had to wrap it in an entire form tag to make it work um and I so much that I made a a component that was simply just a button component you don't like that see I like that about because then I mean that's how it would work without JavaScript you know what I mean yeah yeah that's true like you you maybe do want that but like for example like if you want a button that when you click it it runs off and fetches some stuff it's never going to be run server side it's just a delete button delete something yeah it would be nice to do that so you can you can put them on a button you can put them on um there's a couple other ones I think it's option as well I I know to be clear here about this felt you can actually hit the the server actions with just straight up JavaScript in Sp you don't have to wrap it in a form but I recently did this and I opted to I had like 40 buttons on the

page and I opted to to wrap every single one of those in a form yeah it's true I do like it because it's you're not writing any other functions it's just declarative form right yeah and you give it an action it's true every single if you go in the admin back end of the syntax dashboard there's probably 1,400 buttons on that page you know more than that actually there's there's probably 5,000 buttons on that page and they're all form tags there's probably 5,000 buttons on that page so along with these form uh form action server actions we now have a couple new hooks uh that will allow us to work with these forms so we have used form status status status what am I saying that gives you a reactive variable of if the form is currently being submitted so you can do your loading indicator something something's been submitted to the server side you're waiting for it to come back um use form state is used for displaying error success messages from the backend so if your form needs to return some additional data that needs to be

displayed in the form you can use use form State and then there's a use optimistic hook that will allow you to do optimistic updating so for example an optimistic update would be if you have a to-do list and you add an item and you hit enter you you kind of want that item to be immediately appended to the list of to-do lists you don't want to be sitting around waiting for it to go to the server save it to the database come back say it's successful and then send it back to the to the client because in almost every use case that's exactly what's going to happen successfully so optimistic updates will say yeah this is probably what's going to happen and if it doesn't you can roll it back there's that's what the optimistic um hook will allow you to do and you can display an eror say ah actually that didn't that didn't work after one second of us trying um and most most data handling

libraries will have some sort of optimistic UI built in so again it's nice that it's all built into JavaScript yeah I optimistic UI is one of those easy wins for folks if you want what's perceived performance uh you know often times you're server can be the slower part of it waiting for the database to respond or just those messages to go back and forth but if you add in optimistic UI it feels very fast and it can be with these types of Tools looks like a little bit easier optimistic UI has never been something that has been super easy so I'm I'm really excited to see that they thought about that another example optimistic UI is on Facebook if you leave a comment on Facebook and you put a link in the URL and you hit enter immediately it'll just be a plain text string and what's happening is that Facebook is saving that comment to the database but it's also checking if there

are any URLs and if those URLs have OG images and if that URL has been banned or any of that stuff right doing it in the background yeah exactly so it's doing all of that in the background so immediately you see oh my comment worked um I don't need to hit the submit button again but after uh two seconds or so then you see oh my comment has has been updated with the actual hyperlink link and the open graph image has been embedded into it suspense so we've had react suspense for a while um and this is going to make it really really easy so you can take a react suspense which is a component and you wrap it you wrap components that need may take a while to to render so in an example that I did I put I intentionally made a component that takes 4 seconds to render and if you have a single component on your page that takes four seconds to render guess

Chapter 14 36:30

React Suspense

what is also taking four seconds to show up the entire page right so one little component could make your whole page extremely slow it's kind of promise.all the entire thing so what react suspense will do is you can wrap your possibly slow components or you can wrap anything that fetches data in a suspense component and what what will happen is the server will immediately send a loader component you specify what shows up when you are loading um and you're sort of in a suspended State and you can show a spinner you can show nothing and wait for two seconds and then show a spinner you can show skeleton screen that's pretty common in applications where it's just gray boxes where the content should show up you could show an actual skeleton you could show an actual skeleton uh whatever you want and and then the server will continue working on

rendering that component so not to hold up the rest of the actual website and then the server will stream them from the server into the client when it actually is rendered and um you got to be careful because you you can get a lot of spinners on your page and we've all been on those apps before where there's eight spinners for 3 seconds and then the website slowly comes in but you can also wrap multiple suspense components in a single suspense component uh which is kind of cool so if you had three or four things that were loading and you wanted to say all right I only want to fade it in once everything has been done then you can you can wrap there and it just it works it's you just wrap in a suspense component you give it a loader prop you're done there's no there's no creating custom fetch request quests like it used to be um because it just knows that your server side component is a synchronous and it knows how to handle

it that's nice yes suspense man hey you can't make any more jokes about waiting for suspense anymore that's played in 2024 all right um I told myself I would not sprinkle in opinions too much um but now's the opinion hour so Scott and I are gonna gonna let them fly um opinions what I like it is extremely easy to run things on the server and that client server passing is is effortless um and I a huge fan of that in all of these meta Frameworks being able to just spin up a project and have a client server model rendering out reactivity in like I could probably do it in seven and a half minutes maybe even less you know and like that's that's ideal to me um first class support for forms big fan of that I already said that um what I

Chapter 15 39:13

What we like

don't like unless Scott do you have any any things that you you do or do not do not like I know you haven't use it I'm gonna say here from my perspective yeah I have not used this but I don't really dislike anything that we've mentioned so far I am like I'm optimistic about all this stuff and I'm having a hard time feeling down on too much of it because I typically work in sites that have a tightly integrated backend so for me that's nothing new I typically like to have my data where I use it that's nothing new for me I personally like the form action stuff because that's how I'm used to writing app so all of this kind of to me brings react into a place where I would actually want to use it as react now for me the negatives come in when I think how do I do this do I just use nextjs is

that it do I have to do I have to use next I don't I'm going to be real I don't love nextjs even with all this stuff it's not my favorite platform so if the answer is you got to use nextjs to use all this stuff I'm out I'm sorry um good but uh yeah what what is that how piece it just feels like a big mystery to me next ask was the first framework to this um not sure how much we can say about it but like remix will support this kind of stuff and there was a thread from Ryan Ryan Florence the other day where he was talking about all of these features that remix had and component data loading um there was a whole bunch of them I'll link it up in the show notes but basically said like these we don't need these things in in remix anymore because now react has them and isn't that kind of nice so I'm imagine remix is going to get it uh their support already in tan stack which is kind of wild to think that all the tan stock stuff is kind of it's a

framework in itself you know yeah totally but let's talk about like like what what what's all the push back for this type of stuff like the the big things that I heard from people is a this is a massive rewrite I do not have time to fuss around with another rearching of my application you know like I already did function components to class components then I did class components to back to F or like it was create class then it was class components then it was uh hooks uh and now we we're talking about this whole client server methodology and it's it's a lot especially with the pretty big one so it's a big rewrite um a lot of people said I don't see the benefit our app is fast we don't need this I'm fine with having everything rendered on the client we heard a lot of what happens when there's front end and backend teams you know like you're kind of blurring the lines here and and it's just too complex a lot of people are like I just moved to

Chapter 16 42:02

What we don't like

spelt I moved to Astro I moved to something else because this seems like a lot of complexity for the fact how simple it is in a lot of the other things and and still also like Rea still does not have a like a nice State Management like we obviously have state yeah but you got to prop drill it all the way down and then which which state management Library do you want to use in react that's the other thing a lot of the State Management libraries are broken on this as well because you kind of have two two different um applications right so I think we got to sort of sit and wait to see what the state management solution right now the solution is that you can pass data via props between server and client components and vice versa what other downsides of here you really need to rethink your architecture so I found myself having to split components up into different files quite a bit which you don't like we

we've established that you don't like that or even like as simple as a button MH sometimes you have to put a button a form submit button in another file um and I was notd a major fan of that or sometimes I like oh like my navigation is has like a resize observer in it you know so all of a sudden my entire navigation is no longer a client side server component now it's a client component it would be nice if you could wrap that in a some sort of wrapper to say hey this bit this little tiny bit of JavaScript this resize Observer just execute this only on the client yes and that's what a client component is right but then the other thing is like the you can't get the current page server side in nextjs that was like I was like trying to redo my navigation and I was just like going through all these

threads and um some there was like one of those like threads that have gone off the rails because some guy's like forel is A90 trillion dollar company and can't figure out how to get the server you're the like the current page URL to highlight the current page in your navigation is next to Impossible on the server unless you opt into using cookies which then opts you out of all of the versel caching and like and you just import the freaking page and you get you page you get access the entire URL property whatever you want path name any of that stuff yeah I don't I don't like those butts you know I don't like butts and can we clip that Randy I don't like butt I don't like butts of like yeah yeah I could do that but then I have to convert the whole thing to a server component but then or client component then this piece needs to be a server component so push

those feelings back because I think that we just need more design principles and I will'll probably have a follow-up show in 3 months or so to figure out a little bit more of these architecture examples um oh another downside third third party components so you're importing a component from some Library uh let's let's say react ARA maybe react Arya is is already set up for this but some component that's been made before 6 month months ago it's very likely that that component does not have a used client at the top of it oh right so how so it's so it's a server component by default but it has a a click Handler in it what do you get that should have been the other way around yeah yeah I think they I think they did it by default because you should you should default to server right everything should be server rendered by default you shouldn't have to opt into

server so now you have to wrap you have to make another file that simply just Imports that component o takes all the props or no maybe you can just export from use like the es6 export whatever from but then you just pop a use Ed client at the top of it so annoying yeah that's rough yeah um design patterns let's talk about really quickly everything should be servered by default your highle components should be server components and then you opt into client components as as you need it try to go as small as possible so like a notifications bubble rather than your entire header being a CL client component maybe just the notifications bubble would be a client component parting links here there's a really good Chrome extension all link up there is a another framework you'll be glad to hear a new react framework called

Chapter 17 47:18

Design patterns

waku and waku is a framework like nextjs or gats spear remix that is implemented using react server components from the default and it's from the same Dev as zand yeah I was I was low on waku until I found out who made it and then I'm high on waku yeah and versel is funding it as well so you've you've got to think that between versel react and the guy who made zo stand like one of the best State Management libr is out there it's great you got to think that they think you know what this State Management thing is not solved yet yeah and uh we got to explore this a little further uh m.com is built-in server component so if you're using the Chrome extension I talked about go to m.com and start hovering over URLs you'll see them being preloaded as as you hover over top of them and you'll see the parts come in as

you change pieces on the website and that is it hopefully you enjoyed uh that will'll get into sick pix and Shameless plugs but that is react server components that was a big show I researched the crap out of that for the last couple months so I'm glad appreciate that this one out there yeah yeah I'm feeling very knowledgeable about server components now and I uh yeah I I really uh I I really think the audience is going to get a lot of out of that because as somebody who's only seen the high level about these things I think that gave me a lot deeper insight into what it actually would look like to use this stuff in the real world so uh thank you for doing all that research um now was a part of the show where we get into sick picks and Shameless plugs things we want to pick or plug I'm going to be picking I'm going to go back in time here I'm picking a CD drive or a DD DVD drive um yes I have been I had a big old stack of DVDs and CDs from like old projects and stuff and I've been ripping

Chapter 18 49:25

Sick Picks

all this data whether it's been projects that I've had from a long time ago I'm trying to get all that physical media out of here I'm backing up stuff you know I I just I'm tired of having that stuff around the house so I found this Asus Zen drive with a built-in USBC cable you don't got to power you just plug it right in USBC it's a tiny little itty bitty CD drive and it's $28 so if you are ripping if you got a stack of CDs somewhere that you've just been putting off man this little $28 Drive I just popped it in there functioned great that's so cheap yeah it's amazing that it's so cheap and I went through maybe about you know 200 some DVDs that I had of old school projects whether there were songs you know when I was in I was in school I was constantly working on on music projects or programs or something like that and you know people might not know this but hey my my like C hard drive was only 200

GB and uh even then that thing died so it was important to keep stuff backed up on on DVDs or whatever so you you might be like me and have physical media sitting around and I think this this thing as a little $28 CD drive was super fantastic I'm going to sip pick um I gota make sure I'm not showing my phone number there we go uh Leatherman Arc which is a multi-tool that I EDC everyday carry so I have carried a pocket knife for probably about six years and you may think that's kind of weird especially for our uh like UK and um Irish listeners which apparently it's illegal to carry a knife there but I carry a knife with me all the time everywhere I go because it's super handy I find myself using it from cutting kids chicken nuggets in half to just prying at something popping it open

cutting something I use it probably three times a day um and I've always wanted to carry a multi-tool which is it has a knife it has uh pliers in it it has screwdriver it has bottle opener scissors is probably the most popular one that I use because kids are always asking me to cut the little tags off their clothes or whatever is coming up oh so you end up using those little scissors okay oh I use the scissors probably as much as the knife surprisingly because I used to cut with my knife but the scissors is a lot more controlled especially like you have something that is like zip tied um like you get something like a package and it's zip tied you can the the scissors have really good um leverage on them you can just snip the zip tie rather than trying to pop it open and I am so happy with this thing because I I never liked multi-tools because you always see those guys with them like holster carrying them on the side you know and like I'm

not that guy yet but I always and it has a pocket clip on it and it fits it's not much bigger than my knife it goes really small it has like a couple couple screwdriver bits in it a little micro screwdriver there's Cutters in it if you need to cut a piece of wire and I'm not lying when I say I probably use this five six times a day just for little stuff I don't have to go get a tool when I'm doing something and or like you're always the hero when you like I was you pull out your uh Little Scissors you're the hero yeah we were I was at like a kids function the other day and like somebody had like bumped uh a picture that was hanging in the hallway and it broke and they're trying to figure out oh shoot like I got to fix this thing I just like excuse me and I fixed it with the fers and then I just like walked off into the sunset like the hero of the day so I did a crazy amount of of research on multi-tools and this

is the Leatherman Arc it has the nicest blade it's not cheap but it's one of those things hopefully you don't lose it and you hopefully have it forever and I've been just been my wife got it for me for Christmas and I've been so happy with it yeah how would you is that was that one we'll have to talk about maybe I'm sure Christmas gifts will end up becoming sick pics here we haven't talked much about holiday yeah yeah no I uh I got a list of stuff I got for Christmas that will be upcoming sick picks but this leather mon Arc has been high on my list a has magnets in it that's the other thing is it Clips can we do a whole show on my multi-tool because I I could talk about it forever it's like when I got my uh what's the backpack we have the peak B yeah the peak design bag I got the I think like six or seven years ago before everybody had it and I could not stop talking about how awesome it was to people it is great although the the my only concern with the peak designs backpack is that when I take it through airport security and they stop me CU I have uh audio gear

or or something in my my bag uh they're always like how the hell do I get this thing open like oh yeah you pull down on here and you you twist the knob you bop it you know and then it comes open yeah all right uh Shameless plugs west.com courses for list all my courses uh and I'm going to shamelessly plug the syntax YouTube channel hey we have a YouTube channel and it used to be level up tutorials which is one of the reasons why you'll see a lot of my old content there but for fans of the podcast we're going to be start pushing episodes out there as full video episodes so not just the social Clips you've been seeing here and there so if you want to get ahead of it um sign up for our our YouTube channel go smash that subscribe button and you might even see some additional content from me and others here and there as well I've been doing some kind of oneoff videos there uh for fun

youtube.com sytax FM uh go ahead and smash that subscribe button ring the bell do all that stuff and uh you'll get syntax episodes on YouTube beautiful all right thanks every for tuning in catch you later peace peace

Quote it with credit and a link. Quoting Syntax