bloody confused by the new Next.js server actions

Does anyone understand how server actions are pulled from the code I write and actually run on the server? The next build process confuses me and the information I can find is super sparse (https://nextjs.org/learn/foundations/how-nextjs-works/buildtime-and-runtime ...) Any hints for blog posts or similar that dive into what results from the next build and how it does its thing would be awesome
Learn | Next.js
Production grade React applications that scale. The world’s leading companies use Next.js by Vercel to build pre-rendered applications, static websites, and more.
3 Replies
JustATempest
JustATempest2y ago
For forms, I believe they're natively capable of running some networking, so on submit, They use the legacy features that are baked into forms and how they function. If you use server actions anywhere else, You're using them in a use transition, which is a react feature to run non-blocking code, next hooks into this by doing network calls during this time and putting the results into it like a socket. I'm making an application that uses them extensively and I've gotten quite familiar with some of the caveats. Primarily, They simplify the logic of forms. They don't really mesh with redux as they require use transitionz and I can't figure out how to combine with Redux. You can use them for form submission still, but I wouldn't use them everywhere should you like the remix pattern from my experience. They're also good for routes or components, that don't require a lot of shared state. Tldr; The best way to use server actions is in the forms as they simplify submission, and in client components that mutate the database or load data from the database, where the component does not have shared state with the rest of the application. As of now.
meeepsss
meeepsssOP2y ago
that's helpful for the practical side of how to use them. But i'm coming from a more traditional express backend and separate frontend perspective. What i'm asking is how these server components "become" functions running on the server, rather than client the details are sparse on the forums. For instance, I can't see anything which confirms server actions' code isn't sent to the client and I can't figure out the build process to check this myself! Of course, they must not be but i'd like to know how
JustATempest
JustATempest2y ago
@meeepsss The reason why you can't find anything about server actions implementation It's because they're built a top react actions, which is an experimental react feature. This might be a better search query.
Want results from more Discord servers?
Add your server