BRIEFS logo BRIEFS

Sharing server/client validation logic with @remix_run

05/17/2021 , 2m, 55s

Hey friends, so I'm working on this little remix app and just something about remix that I just this so cool the fact that your server and client side code run is written in the same file if in case you didn't know that that's that's what you do and it's really cool for validation so you can start by validating just a hundred percent on the server and remix makes it quite nice to be able to do that and that's where your validation should absolutely.

100% go by default that's like if you're gonna do it anywhere do it right there, but having client side validation can be nice for you know, showing error messages and stuff and so because the client side and silver side code is written in the same file, you don't want to like duplicate that that logic and so you just extract it to a function and then in the server you call that function and the client you call that function and when remix shakes out all of the stuff that function will appear in both places, but you don't have to write it twice and so.

I'm just writing out a form right now and I had a a maximum length for a particular field and so I can just put that variable outside of everything and make sure that I only have one specific place where I say what the max length of this is gonna be and then I just use it in the client and in the server all in that same one file.

I don't need to like put in a different module and import it or anything it's all just right there and I just think that's awesome that I I'd share that with you remix is just my friends it is something else. IFeel super productive working with this and yeah I the cool thing is that it's I feel like it's both pretty quick to get at for it to become familiar so it doesn't take the long for it to become easy relative to other stuff that I've worked with but it also seems so simple and so therefore I can build simple applications with it and and and and I I mean, I haven't written an application in a million lines of code with remix and,You think but I feel like this would scale well to that based on the experience I have in writing and working on enormous applications, so yeah anyway remakes it's it's awesome and I know that I gush over it but there's a reason it's not it's certainly not because Ryan and Michael are paying me in fact I paid them to be able to use it so there's there's no conflict of interest there, they're my friends, so they're there's a full disclosure but this thing is out of this world, so if you haven't taken a lucky remix yet and give a good look at it.

See ya.