How I structure my next.js applications

preview_player
Показать описание
My Products

Useful Links
Рекомендации по теме
Комментарии
Автор

We need more videos like this, coding tutorials are everywhere but no one is teaching architecture specific to a framework, i usually struggle to decide what goes where, great video

georgemwaniki
Автор

Thank you Cody! I’ve been developing in Nextjs for a while but seeing the perspective from a senior developer is unbelievably valuable

NizzyABI
Автор

Good to see you back babe! Love ya! Great job

SeibertSwirl
Автор

I’m loving Supabase right now. The business layer fits in really well with Postgres functions and edge functions.

funkdefied
Автор

Colocation makes the most sense. I don't know why I didn't think to apply this to server actions. Great video.

dcmbassi
Автор

I knew something was wrong with how I was coding but didn't know what it was, this video is what I needed - ty!

tyeinstem
Автор

Great video! I've been thinking about how I could use clean architecture in NextJS. You even touched upon a few concepts from Domain Driven Design in there. Cheers!

tiagodev
Автор

Really liked this. I feel Nextjs is overly complicated for the apps that I'm working on currently, so I'm sticking with bun + vite, which is very fast and stable. So hope you do some content for that too :)

maddada
Автор

Your style of teaching is extremely helpful.
I would love to see how you would approach having the "backend" aspect be decoupled from NextJS. For instance, when using a shared backend across multiple applications. I imagine the only difference would be that the business layer would be an external api, which then handles the persistence and database layers. Unless I'm missing something.

bucketcodes
Автор

Hii Cody, I like this architecture type, everything gets way cleaner and its kinda looks like a backend architecture with Controller and Services, I love it !

I have one question, inside the data-access & uses-cases files do we need to put « use server » ? Or maybe import server-only ? I thought it was necessary 🤔 (even tho I don’t know the difference between both of them lmao)

endlessia
Автор

Is it possible to teach yourself Clean Architecture? I remember trying to read the book and everything went straight over my head lol.

codinginflow
Автор

Helpful video. I split along the same lines. This is honestly why the nextjs paradigm feels off to me because you can end up mixing your code into a spaghetti pile. But hey, as long as we get rid of the spinners 😂

al
Автор

Your work is exceptional. I am inspired by your videos and the fresh insights I gain from them. It makes me wonder if there's something new I may have overlooked. It would be great if you start adding unit tests as well. Keep up the great work.

Imk_Aslam
Автор

Yea! I think your the only person talking about this topic in Nextjs community

caseyspaulding
Автор

Hi, I use a very similar structure, except for some projects that I want to advance quickly, I unify the business layer with the persistence layer, but the separation of the view/controller layer is always there, it is super important. I communicate them with DAO objects.

raphauy
Автор

16:45 would you also recommend co-locating your unit-tests? So your unit tests would be in the same directory as the function that it is testing.

Ahmed_
Автор

In the past, you would have recommended to do dependency injection on the use-cases or business logic so that it's not dependent on any external libraries (in this case drizzle-orm). Would you say injecting dependencies is just more cumbersome now and you're okay to have your business logic tied to the database repository functions or would you still dependency inject? I'm asking because I'm having the same issue

williamx
Автор

this is useful stuff. Thanks for the video, cody!

boy-zc
Автор

Amazing!!
can you add a second part to the video how you decide what files should have try, catch ? what files shouldn't have it and just throw errors ?
how toast work with actions ? and maybe a user auth with custom jwt and not using clerk ?
also, how can we use webhooks with this architecture? and 3rd party integrations.

guy-dkcy
Автор

Hey there, great video! Glad to see that we have a very similar approach. I've been trying to figure out myself when fetching data in server components. I've been checking if the user is authenticated before fetching, but here's what I'm thinking: if the page is protected and the user has to be authenticated for the page and the component to render, the fetch call will never be made by an unauthenticated user, right? So, it's automatically protected. But i still do it anyway.

ahmedbg