Ditch useEffect for Next.js Server Components

Most React devs bring their SPA habits into Next.js — and their users pay the price. 👇 You've written it a hundred times: useState for data, useEffect to fetch it, a spinner while they wait. It works in React. In Next.js App Router, it's the wrong pattern entirely. Server Components let you fetch data inside the component — on the server, before the page hits the browser. No loading state. No extra JS bundle. No hydration issues. HTML that arrives ready. I've swapped dozens of useEffect fetch patterns for async Server Components and the Lighthouse scores jump immediately. Use the server for reads. Use useEffect for things only the browser can do. #NextJS #ReactJS #WebDevelopment #JavaScript #TypeScript #AppRouter #ServerComponents #ReactHooks #FrontendDeveloper #SoftwareEngineer #CleanCode #100DaysOfCode #WebPerformance #Programming #WebDev #NextJS14 #FullStackDeveloper #CodeQuality

  • graphical user interface, application
Rommy Taufik Hidayat

Frontend Developer | Mobile Developer | React Native Developer

1w

is using tanstack query same as spa things?

Like
Reply

Waseem Talib Thank you for sharing this. These images have a lot of details showing that you can build a full-stack app with NextJS, no backend server or frontend app, just one app, so the React SPA pattern can show up because NextJS uses React, and with this, a developer can choose to use that SPA pattern, which will work, but as you keep build with NextJS you will learn its best practice and performance optimizations.

Like
Reply

But there is shown that there are not loading, but you just change responsibility to server, you still have to wait when server return list to you so you have to show loader with suspence approach

Like
Reply

Thanks for reminding me, I always forget to use revalidate.

See more comments

To view or add a comment, sign in

Explore content categories