Next.js 14
Tags: webdev, react, frontend, nextjs
Published: 2023-11-07 04:11:17

I attended the Next.js Conference 2023 in person and I had a great time listening to the talks, talking to people way smarter than me, and getting free food and swag. The main theme of the conference seemed to be about getting people to transition from the Pages Router to the App Router. I already use and love the App Router so I did not learn much from those kinds of talks.

If you are still on the fence about App Router and React Server Components, then I recommended watching [this talk](https://www.youtube.com/watch?v=9CN9RCzznZc) by [Sam Selikoff](https://twitter.com/samselikoff), who gives great talk that explains how these features execute React’s goal of composable UI.

The [keynote about Next.js 14](https://www.youtube.com/watch?v=gfU1iZnjRZM) by [Guillermo Rauch](https://twitter.com/rauchg) was great. This major release is focused on improving current features and aiming for stability. You can read the [official blog post here](https://nextjs.org/blog/next-14) for more in-depth read. I am excited that **[Server Actions](https://nextjs.org/docs/app/building-your-application/data-fetching/forms-and-mutations)** are now stable and am looking forward **Partial Prerendering**.

### Server Actions

First off, if you don’t know what [React Server Components](https://nextjs.org/docs/app/building-your-application/rendering/server-components) are, I suggest reading up on it before continuing. I also wrote an [article about it and NextJS features](https://www.linkedin.com/pulse/learning-nextjs-react-full-stack-features-junsu-park/), including Server Actions, with lot of simple examples and pictures.

Server Actions allows you to invoke server functions from the client without needing to explicitly define an API endpoint and write a request to that endpoint. NextJS will handle all of that for you.  You can also send data from the client to the server function.Simply mark a function with “use server” at the top and everything inside will only live and execute on the server.

![Converting API endpoint and client-side request into Server Action](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m87663qfgsq9qqeo9ao2.png)

There were people pushing back on Server Actions with the usual worry about separation of concerns, which is expected whenever [React does anything](https://youtu.be/8pDqJVdNa44?t=2439). I agree with what React and NextJS is doing - concerns should be component based. I personally believe this improves DX through easier mental models and improved code maintainability. All the code required to render some piece of UI will all be in one file (especially if you use CSS utility libraries like Tailwind). 

Other frameworks also have ways of defining server-only code, such as [Solid](https://start.solidjs.com/api/server) and [Qwik](https://qwik.builder.io/docs/server$/). And I’m excited to see how this new paradigm grows.

### Partial Prerendering

I recently wrote a [basic summary of server side rendering](https://www.linkedin.com/pulse/server-side-rendering-whats-ssr-ssg-isr-build-time-request-junsu-park), and in it, I talk about the difference between build time - more accurately, ahead of time - and request time. There was one thing I did not mention for sake of conciseness which is that it’s all or nothing. If your page was static but had just one tiny part that needed to be dynamically rendered, you either had to:

1. Pre-render it all at request time


![Visual of traditional server-side rendering](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pi4bjgv5t5lb4y0320xe.jpg)


![Rating traditional server-side-rendering with slow initial visual](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6mn68ok6of96lh1jjrob.jpg)


2. Or pre-render everything else ahead of time and make the client fetch the dynamic data and render it themselves.



![Visual of static + client fetch](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m0dv0rm8g9s9b0s3c4g9.png)


![Rating static + client fetch with slow dynamic visual](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ytmn4s7ws6ridisb2p0k.png)

What if there was a way to render all the static content, such as the navbar and footer, ahead of time? All the static content will be served immediately when the client makes a request. Then the dynamic content, such as product information, can be rendered and streamed in later. Partial prerendering is exactly that.


![Visual of partial prerendering](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3xcpd8tazidu8kxhc0v5.png)

![Rating partial prerendering with fast initial visual and fast dynamic visual](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5dsdc0o4nkj6rhn73e3s.png)

No waterfalls. No new API - this is all done through React Suspense.

This feature is not released yet but I’m very excited to try it out.

### Conclusion

Next.js is an already amazing production-grade framework with great developer experience and it keeps outdoing itself with every release. They fully enable React to be used to its fullest extent in the easier manner possible. And I can’t wait to see what comes next.