,

Is There a Catch to the New Approach of Writing NextJS?

Posted by






The New Way to Write NextJS: What’s the Catch?

The New Way to Write NextJS: What’s the Catch?

NextJS has become one of the most popular tools for building modern web applications with React. With its server-side rendering capabilities and seamless integration with React, it has become the go-to choice for many developers. However, the new way to write NextJS has some developers questioning if there is a catch.

Introducing NextJS 12

NextJS 12 introduces a new way of writing NextJS applications with the introduction of the getServerSideProps and getStaticProps functions. These new functions allow developers to fetch data and even perform server-side rendering without the need for a custom server or middleware.

What’s the Catch?

While the new way of writing NextJS applications certainly has its benefits, there are some potential drawbacks to consider. One of the main concerns is the increased complexity introduced by these new functions. Developers may find it challenging to understand and implement these new features, especially if they are new to server-side rendering.

Another potential catch is the impact on performance. The new functions may introduce additional overhead and complexity, which could have an impact on the overall performance of the application. Developers will need to carefully consider the trade-offs and potential performance implications before adopting the new way of writing NextJS.

Conclusion

The new way to write NextJS with the introduction of getServerSideProps and getStaticProps offers a powerful new way to handle data fetching and server-side rendering. However, developers should carefully consider the potential drawbacks and weigh the trade-offs before adopting this new approach. With proper consideration and planning, the new way of writing NextJS can offer significant benefits for building modern web applications.


0 0 votes
Article Rating
41 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Zarak Khan
7 months ago

"the frontend and backend code has never been so tightly coupled before" dude! do you even know PHP!!!

snatvb
7 months ago

you can use it where security is not necessary now
I understand the security concerns and share that

The_Boglodite
7 months ago

Is it just me, or does this seem like way more of a pain in the ass than before?

Miftaul Mannan
7 months ago

Api should always be separate. I don't see much use of server actions in a production grade app.

Luis Miguel Torres
7 months ago

I understand this is experimental but it would be easier if instead of defining the action within the component, a better and more clear way would be something like sveltekit with a file located withing the page directory called actions.ts or _actions.ts, which would make the usage more clear and allows you to properly handle your imports in your app and defining where server and client code is running. I know you can define your actions in a different file, but this way you wouldn't need to add the "use server" for your actions and it would allow you to use your actions more as an API.

Long Nhat
7 months ago

Well said video!

Ilya Tegmark
7 months ago

Cool thanks

Khaled SANNY
7 months ago

I want to ask something … since Next want us to use server components to fetch data, and now use server actions to perform mutations, does this mean we don't need libraries like React Query and SWR ? Because it behaves exactly like those. Too much untold about those new features, I think

patite
7 months ago

Could you please do a video on the server actions (Next.js 13.4) with a small project like putting information in a form and updating a MongoDB database? thank you

KINAY Mick
7 months ago

Hi, I'm really new and trying to learn NEXT js. Do I still need API to fetch data from my own db or can I just put the Function of the API in a server action?

Kasun Lakshitha
7 months ago

Man, you are so helpful. I found you recently on youtube, and I watched some videos. I liked your videos because you always talk about the negative side while discussing a topic. Keep it up, bro!

William Will
7 months ago

Thanks for the video!

It's not super clear to me how server actions relate to the new app router, particularly because the router is stable but server actions are experimental.

Also, if server actions are still experimental, is this really the new way to write nextjs apps?

sad kebab
7 months ago

5:20 I am not getting this… this code snippet doesn't leak anything to the client even if you try hard to make it leak by removing use server clauses (and I tested it several times).
Can anybody explain where the issue is properly?
Every comment I read about that screenshot sounded like pointless alarmism to me.

Brian McBride
7 months ago

Tightly coupling server code with client code isn't a great idea at enterprise scale.
For a smaller site, sure. Why not?
Just keep in mind that skipping building proper API or other data interfaces is exactly where we started with web dev 10y ago. Yes, the tightly coupled monolithic approach is easier for the single developer. Nothing NextJS is doing is new in concept. Even partial DOM refresh was accomplished in JSP/ASP pages way back when.
How will all this SSR trend with React affect poor internet connection?

Shift
7 months ago

can you make a video making or showing a backend with nodejs that uses the new postgres database vercel and showing the backend deploy?

blaize
7 months ago

But how safe is this, to use it on a "real" app? Aren't there any exploits or bugs (i know this is a alpha/ beta feature, but still) that can be abused?

chawki challadia
7 months ago

next slowly becoming php 😂

Pedro Zurita
7 months ago

This is the spaghetti that first offput me from React and now Next has taken spaghetti and mixed it with angel hair and fettuccine and it's all kinds of looptyloops. Mix this into the file and that and a little bit here. Just makes me a bit 🤢

YetseEvad
7 months ago

I think if you are doing solo full stack projects, the distinction isn't a must. But for teams, and any production code (even if it is stable), it is better separate because of understandability for others using/adding to your code.

Alexander Komanov
7 months ago

Thanks a lot!