everyone here that talks about coding seem to focus a lot on retro web development, but ive never seen anyone here talk about actual modern web development. so why not talk about the trendy framework the cool kids are using?
well, i made a couple of projects using nextjs and i have to say - what a mixed bag. i wanna talk about two things.
FIRST - server side rendering.
i love nextjs but at the same time i hate it. i think the main reason for me to hate it is because sometimes it makes it hard to make client-side code when that shouldn't be hard.
nextjs is SSR-first, so you use server components most of the time. however, it also prerenders EVERY client component you do. this ain't much of a problem most of the time but sometimes, you wanna use a browser-specific API (like localStorage, for instance) but in order to do that, you have to do some weird changes. the two options you have are:
- create an isClient state, in which the component returns null if it isn't on the client
- manually lazy load the client, disabling ssr entirely and using a loader fallback when it's loading
...which results in ugly code most of the time. that's my major issue.
i think server components should NOT BE THE DEFAULT - client side rendering should be the default, and if necessary, the developer should opt-in to server-side rendering. THAT feels much more intuitive for me.
SECOND - server actions.
this one has actually good premises. its a TRPC-like architecture where you define functions that run entirely on the server. great for mutations!
...the thing is that, error handling is a bitch. you can't throw errors because next.js sanitizes error messages in order to prevent code info leaking (WHICH IS DUMB) so you gotta catch the errors and return your own error object (something like "{ error: "something happened" }")
and in order to show that error, its just so much code for so little. you dont even know if that error object is even defined so theres a lot of "?" in the code and stuff like that. it sucks. why be type-safe if you dont even know if thats valid on the first place?
what solved this for me - the next-safe-action library. PLEASE USE THIS SHIT. IT HAS CHANGED EVERYTHING FOR ME.
no more shitty type coersion and validation, you pass in a zod schema, do your stuff, done. you can even directly return validation errors. AND it even has react-hook-form integration!!! i use it all the time.
ill still make projects with this framework, but it has its weird nature and having to use libs for a good developer experience. still a powerful tool with the file-based routing and SEO helper functions.
Comments
Displaying 2 of 2 comments ( View all | Add Comment )
cherrytamagochi
viva a nerdice
☝🏻
possuo meu certificado de virgindade em mãos 🙏
by maciel; ; Report
Y3k_Nath
amo ver tudo oq vc posta, Maciel
apesar que em 79% dos casos eu não entenda sobre nada do que vc fala e precise usar tradutor KAKAKAKSK
awwww :(((
obg nath, tava esperando menos respostas nesse post justamente por conta que além de ser em inglês, eu tô falando de algo mt específico de programação. significa bastante!! :))
by maciel; ; Report