Next.js Discord

Discord Forum

Next.js Best Practices in 2024

Answered
Grass carp posted this in #help-forum
Open in Discord
Avatar
Grass carpOP
Hello everyone, I am a front-end developer and a next.js beginner. Here are some libraries I have been learning recently about react and next.js, but I found that the React ecosystem is too rich. I don’t know which are the best practices for next.js in 2024. Do I have to learn all of them, or which libraries are more popular?
1. Prisma, drizzle or typeorm?
2. React query or swr, or nothing?
3. Is trpc necessary?
4. What is the state management solution? I just used zustand recently
5. Is react-hook-form necessary, or should I use native action
6. Do I need a permission solution? What about auth.js?
Answered by Lukas
1. Drizzle seems to be trending at the moment.
2. If you're using app directory, likely nothing. Grab react query if you end up doing lots of client fetching.
3. Same as above. Do you need the end-to-end type safety? If you're fetching data on the server with a orm, you might not. You can always add it later if you have an api that you need types for. If all you're doing is just fetching from the db serverside and using server actions, you probably don't need it.
4. Zustand is great, jotai (made by the same person) is great too (and considered simpler). Take a look at both and see what you need for your project.
5. Use server actions. With useFormStatus and useFormState, you can basically do everything (besides multi-page forms.)
View full answer

6 Replies

Avatar
1. Drizzle seems to be trending at the moment.
2. If you're using app directory, likely nothing. Grab react query if you end up doing lots of client fetching.
3. Same as above. Do you need the end-to-end type safety? If you're fetching data on the server with a orm, you might not. You can always add it later if you have an api that you need types for. If all you're doing is just fetching from the db serverside and using server actions, you probably don't need it.
4. Zustand is great, jotai (made by the same person) is great too (and considered simpler). Take a look at both and see what you need for your project.
5. Use server actions. With useFormStatus and useFormState, you can basically do everything (besides multi-page forms.)
Answer
Avatar
6. next auth is generally the way to go. if you like wasting money and being lazy, you can also use clerk. If you're using something like supabase, their built-in primitives work great too. Just don't try to build your own system from scratch.
Avatar
I can speak just about myself and would answer you:
Prisma, drizzle or typeorm?
Drizzle

React query or swr, or nothing?
React Query

Is trpc necessary?
No

What is the state management solution? I just used zustand recently
React states are best

Is react-hook-form necessary, or should I use native action
No, use normal state management and use the KISS principle

Do I need a permission solution? What about auth.js?
Depends on your app. If needed yes, else no. NextAuth > auth.js
Avatar
Grass carpOP
I really appreciate your answer.
I really appreciate your answer.
Avatar
please mark solution