Next.js Discord

Discord Forum

Next.js and MySQL

Answered
Router Renegade posted this in #help-forum
Open in Discord
hey, In NextJS, how can I make it such that Data should come from MySQL database when a button is clicked? I am using Prisma ORM?

Is it ideal to use the CRUD operation?
Answered by B33fb0n3
you can either use a server action or route handlers. However using server actions there are some disadvantages with it, so you might want to use route handlers to fetch data onClick. Keep in mind to use a clientside fetching library like react query or swr
View full answer

14 Replies

@Router Renegade hey, In NextJS, how can I make it such that Data should come from MySQL database when a button is clicked? I am using Prisma ORM? Is it ideal to use the CRUD operation?
you can either use a server action or route handlers. However using server actions there are some disadvantages with it, so you might want to use route handlers to fetch data onClick. Keep in mind to use a clientside fetching library like react query or swr
Answer
@Router Renegade Thanks
Happy to help. Please mark solution
I am new to this server :hmm:
oh wait
Done
okay?
yes, that worked 👍