When to use server actions in Next JS 14

  Рет қаралды 7,000

WebDevEducation

WebDevEducation

Күн бұрын

⭐️ webdeveducation.com
🎓 When to use api route / route handlers or server actions in Next JS 14 app router.
🔔 Subscribe if you want more free tutorials like this one! kzfaq.info...
Vercel's video on 10 mistakes developers make when using the app router:
• 10 common mistakes wit...
#nextjs14 #serveractions #nextjstutorial

Пікірлер: 19
@WebDevEducation
@WebDevEducation 5 ай бұрын
Let me know if I've forgotten any scenarios!
@user-ru8hn9hb5c
@user-ru8hn9hb5c 5 ай бұрын
Thank you for the amounts of valuable knowledge you put out for free!
@WebDevEducation
@WebDevEducation 5 ай бұрын
You're welcome 😊🙏
@iancarr3923
@iancarr3923 4 ай бұрын
Very useful, thanks.
@u-def
@u-def 5 ай бұрын
I didn't event think that server action doesn't support streaming, So I was wondering what is the differences when I saw the title of your video. But this video really informative and not unneccessary long. Thank you KZfaq tells me this channels.
@liangfamily
@liangfamily 5 ай бұрын
Awesome! It’d be great if you follow up with code examples in the future
@Skillthrive
@Skillthrive Ай бұрын
Another one I came across is when the payload would be over 1MB because that's what server actions are limited to.
@richardmacarthy8569
@richardmacarthy8569 Ай бұрын
Tom, my main man! How's it going? Long time no see haha. Thanks for the pointers. Much love x
@WebDevEducation
@WebDevEducation Ай бұрын
Haha no way Richie Mac! All good here man hope things are well with you!
@jovanjevtic1620
@jovanjevtic1620 5 ай бұрын
So, if I already created a website with nextjs and server actions and want to build a mobile app, I should then create api routes for all those server actions to cover same functionality in mobile app? (or whole another express server)
@WebDevEducation
@WebDevEducation 5 ай бұрын
Yes that's correct 👍
@ismaeltinta6118
@ismaeltinta6118 5 ай бұрын
​@@WebDevEducation I had the same question. I am building a listing directory web app with nextjs and would like to build the mobile version of it using expo. Is it a best practice to use route handlers for the webapp and tanstack query for instance for the mobile app?
@WebDevEducation
@WebDevEducation 5 ай бұрын
Yes it sounds like you'd want to use route handlers for this scenario which can be called from anywhere (within your next app or from an external web / mobile app). Thinking about it though, I might still use server actions for the next app (because a lot of the time server actions tend to be a bit more granular and less RESTful), and create a more RESTful API using route handlers for the mobile app (or any other external app). That way you could fully optimise your next app rather than being tied into a more RESTful API which might not be optimised for the way your next app needs to fetch its data. TLDR; I'd use server actions for the next app, and create separate API endpoints / route handlers for any external apps.
@ismaeltinta6118
@ismaeltinta6118 5 ай бұрын
@@WebDevEducation Thanks for the insights. Really appreciate. I thought I would be locked in an either-or situation, but glad to know I can still use sever actions for the web app. Thanks again
@umer8509
@umer8509 5 ай бұрын
Can we use server action in next if we have a backend in laravel?
@WebDevEducation
@WebDevEducation 5 ай бұрын
Server actions can only be called from within a next app.
@adarshrathi8265
@adarshrathi8265 4 ай бұрын
i want suggestion this type of examples const onSubmit = async (values: z.infer) => { try { const url = qs.stringifyUrl({ url: "/ api /channels", query: { serverId: params?.serverId } }); await axios.pos t(url, values); form.reset(); router.refresh(); onClose(); } catch (error) { console.log(error);, in server action how we manage StringifyUrl, any idea, because it create me a lot trouble.
@b166er4
@b166er4 3 ай бұрын
i use it as you ... just i try to never fetch data in client component... as it is possible, always fetch in async page and pass data as props to client components ...
@TabuHana
@TabuHana 5 ай бұрын
this is self explanatory i feel, but nice vid
10 common mistakes with the Next.js App Router
20:37
Vercel
Рет қаралды 184 М.
How To Use Next.js 14 Server Actions
21:06
Brett Westwood - Software Engineer
Рет қаралды 22 М.
Next.js with a separate server - good idea?
22:53
ByteGrad
Рет қаралды 48 М.
Enums considered harmful
9:23
Matt Pocock
Рет қаралды 194 М.
I Didn't Know Next.js Server Actions Could Do This!
6:53
James Q Quick
Рет қаралды 4 М.
WTF Do These Even Mean
13:44
Web Dev Simplified
Рет қаралды 75 М.
Don't Make These Next.js Mistakes
13:01
Dave Gray
Рет қаралды 21 М.
React + Servers = Confusion
20:30
Theo - t3․gg
Рет қаралды 40 М.
This Data Fetching Combo is OP
7:19
Josh tried coding
Рет қаралды 51 М.
State Managers Are Making Your Code Worse In React
13:33
Web Dev Simplified
Рет қаралды 156 М.