⚠️ One small mistake can silently kill your Next.js performance Most developers don’t even realise they’re doing this 👇 ❌ Problem (very common) export default async function Page({ params }) { const post = await getPost(params.slug); const views = await getViews(params.slug); // 👈 dynamic return ( <article> <h1>{post.title}</h1> <p>{views} views</p> <div>{post.content}</div> </article> ); } 😬 Looks fine… but here’s the issue: Because "getViews()" runs on every request → the entire page becomes dynamic 💥 Impact → No static HTML → No CDN caching → Slower page load → Higher server cost 🧠 Why this happens Next.js rule: 👉 If ANY top-level data is dynamic 👉 The WHOLE page becomes dynamic 🚀 Better approach Move dynamic logic into a separate component and wrap it with Suspense 👇 function Views({ slug }) { const views = await getViews(slug); return <p>{views} views</p>; } import { Suspense } from "react"; export default async function Page({ params }) { const post = await getPost(params.slug); return ( <article> <h1>{post.title}</h1> <Suspense fallback={<p>Loading views...</p>}> <Views slug={params.slug} /> </Suspense> <div>{post.content}</div> </article> ); } ✨ What improves? → Page loads instantly (static content first) → Only small part loads later → Better UX + performance ⚡ Concept: Partial Prerendering (PPR) 🟢 Static → instant 🟡 Dynamic → streamed later 🎯 Takeaway Modern Next.js performance is about: ✅ placing dynamic logic correctly ❌ not over-optimising everything Once you get this… you start building faster apps by default ⚡ Did you know this before? #nextjs #reactjs #webperformance #frontendarchitecture #javascript
Ajay Nagotha’s Post
More Relevant Posts
-
𝐓𝐡𝐢𝐧𝐤𝐢𝐧𝐠 `React.memo` 𝐦𝐚𝐤𝐞𝐬 𝐲𝐨𝐮𝐫 𝐜𝐨𝐦𝐩𝐨𝐧𝐞𝐧𝐭𝐬 𝐩𝐞𝐫𝐟𝐞𝐜𝐭𝐥𝐲 𝐩𝐞𝐫𝐟𝐨𝐫𝐦𝐚𝐧𝐭? 𝐓𝐡𝐢𝐧𝐤 𝐚𝐠𝐚𝐢𝐧. Many of us reach for `React.memo` to prevent unnecessary re-renders in child components. And it works wonders... most of the time. But here's the catch: `React.memo` performs a shallow comparison of props. If you're passing object, array, or function props, even if their internal values haven't changed, a new reference is created on every parent re-render. This new reference makes `React.memo` think the prop has changed, leading to an unwanted re-render of your memoized child component. ```javascript // Parent component re-renders: const data = { id: 1, name: 'Item' }; // New object reference! <MemoizedChild item={data} /> // Or with a function: const handleClick = () => console.log('clicked'); // New function reference! <MemoizedChild onClick={handleClick} /> ``` The solution? Pair `React.memo` with `useCallback` for functions and `useMemo` for objects/arrays. ```javascript // In Parent component: const memoizedData = useMemo(() => ({ id: 1, name: 'Item' }), []); const memoizedHandleClick = useCallback(() => console.log('clicked'), []); <MemoizedChild item={memoizedData} onClick={memoizedHandleClick} /> ``` This ensures your props maintain the same reference across renders, allowing `React.memo` to truly shine. It's a small detail, but crucial for optimizing complex applications. How aggressively do you memoize in your React apps? Share your go-to strategies! #React #ReactJS #FrontendDevelopment #WebPerformance #JavaScript
To view or add a comment, sign in
-
Your website might be slower than it needs to be — and you probably don't even realize it. After more than 5 years of building high-performance web applications, I've seen the same performance killers pop up again and again. The good news? Most of them are fixable in under an hour. Here are 5 things that might be killing your website performance right now: 🔴 No Code Splitting Shipping your entire JavaScript bundle upfront. Break it into smaller chunks and load only what's needed per page. React, Angular, and most modern frameworks support this out of the box. 🔴 Blocking Third-Party Scripts Analytics, chat widgets, and tracking pixels loading synchronously. Move them to async or defer, or better yet — load them after your critical content renders. 🔴 Missing Browser Caching Making users re-download the same assets on every visit. Set proper cache headers for static files. Your returning visitors will thank you with faster page loads. 🔴 Unminified CSS & JavaScript Serving development code in production. Minify and bundle your assets. This reduces file sizes by 20-30% instantly and improves parse time. 🔴 Unoptimized Images Loading full-resolution images when you only need thumbnails. Use modern formats like WebP, implement lazy loading, and compress without losing quality. This alone can cut load times by 40-60%. The impact? Faster load times = better user experience = higher conversions = happier customers. Most performance issues aren't about fancy optimization tricks — they're about fixing the basics that got overlooked during development. What's one performance fix that made the biggest difference for your project? Would love to hear your experiences. #WebPerformance #FrontendDevelopment #WebDevelopment #ReactJS #Angular #JavaScript #PerformanceOptimization #WebDev #SoftwareEngineering #UserExperience #CodeQuality #TechTips
To view or add a comment, sign in
-
12 Powerful Techniques to Optimize Your React Application 🔥 1. Image Optimization Use modern formats like WebP, compress images, and serve responsive sizes ⚡ 2. Route-Based Lazy Loading Load pages only when needed using React.lazy and Suspense 🧩 3. Component Lazy Loading Avoid loading heavy components upfront 🧠 4. useMemo Memoize expensive calculations 🛑 5. React.memo Prevent unnecessary re-renders 🔁 6. useCallback Avoid recreating functions on every render 🧹 7. useEffect Cleanup Prevent memory leaks and manage side effects properly ⏱️ 8. Throttling & Debouncing Optimize API calls and event handlers 📦 9. Fragments Reduce unnecessary DOM nodes ⚡ 10. useTransition Keep UI smooth during state updates 🧵 11. Web Workers Handle heavy computations in the background 🌐 12. Caching with React Query Reduce API calls and improve user experience 💡 Apply these techniques to take your React apps from average → production-grade performance 👉 Save this post for later 👉 Repost with your developer friends 👉 Follow Mohit Kumar for more content like this #ReactJS #WebDevelopment #Frontend #JavaScript #Performance #CodingTips #ReactDeveloper #MERN #Tech #MohitDecodes
To view or add a comment, sign in
-
💡 CSR vs SSR — Why this actually matters (real bug I faced in React) Recently, I encountered a small but interesting issue while working on a React project. I was using window.innerHeight to fix a scroll-related bug (triggering logic when the user scrolls down). It worked perfectly in my app… Until I realized something important 👇 👉 This logic would break in Server-Side Rendering (SSR). That made me revisit a fundamental concept: CSR vs SSR 🔹 What is Client-Side Rendering (CSR)? 👉 In CSR, the browser builds the UI How it works: Browser requests a page Server sends a minimal HTML file JavaScript loads React renders the entire UI in the browser Server → HTML (empty) + JS Browser → builds full UI 👉 This is why React apps (CRA/Vite) are called Single Page Applications (SPA) Environment: Runs inside browser 🌐 window, document are available ✅ Pros: Smooth navigation (no reloads) Great for dashboards, internal apps Cons: Slower initial load SEO is weaker 🔹 What is Server-Side Rendering (SSR)? 👉 In SSR, the server builds the UI first How it works: Browser requests a page Server runs React code Generates full HTML Sends ready UI to browser Browser displays instantly React hydrates (adds interactivity) Server → ready HTML Browser → shows immediately → hydration Environment: First run happens on server 🖥️ No browser APIs (window, document) ❌ After hydration → browser takes over ✅ Pros: Faster first load Better SEO Content visible immediately Cons: More complex setup Requires server/framework (like Next.js) ⚠️ The real issue I faced I used: window.innerHeight 👉 Works perfectly in CSR ❌ Breaks in SSR with error: window is not defined ✅ The fix Make sure browser-specific logic runs only on client side: (hydration) useEffect(() => { // safe to use window here }, []); 🎯 Key takeaway Not all JavaScript runs in the browser. Always know where your code executes — server or client. 🚀 Why this matters Prevents production bugs Essential for SEO-based apps (e-commerce, blogs) Important when using frameworks like Next.js Helps you write scalable, reliable code Understanding this small difference can save hours of debugging and make you a better developer. #React #JavaScript #Frontend #WebDevelopment #SSR #CSR #NextJS
To view or add a comment, sign in
-
Practicing React & JavaScript ✍ Built a simple shopping UI where I used: .map() to render products dynamically .filter() to handle category selection Starting to understand how real apps manage and display data. Next: improving cart functionality. #React #JavaScript #Frontend
To view or add a comment, sign in
-
-
🚀 Just shipped a powerful Contacts Management System — and this one felt different. Not just another CRUD. Not just forms and tables. I challenged myself to build something that actually *feels modern*. ✨ What I focused on: 🔍 Instant search with clean filtering 📊 Smart sorting (ASC/DESC toggle) 🧩 Dual view system (List + Grid) ⚡ Seamless pagination with state memory 🪟 Modal-based creation (no page reloads) 🔗 URL-synced state (refresh-proof UX) The biggest lesson? 👉 Users don’t care about your code… they care about how it *feels*. Every small detail — from switching views to preserving filters — adds up to a professional experience. Still growing. Still refining. But this is one step closer to building production-level systems. If you're working with Laravel + React (Inertia), let’s connect and share ideas 🤝 #Laravel #ReactJS #InertiaJS #FullStackDeveloper #WebDevelopment #SoftwareEngineer #BuildInPublic #DeveloperJourney #ProgrammingLife #UIUXDesign #JavaScript #PHP #TechPakistan #100DaysOfCode #LearnToCode
To view or add a comment, sign in
-
**Next.js 15 Server Components — the end of client-side rendering?** Not quite. But it *does* feel like a major shift in how we build for the web. For years, frontend development leaned heavily on client-side rendering: - ship more JavaScript - fetch data in the browser - hydrate everything - hope performance holds up With **Server Components in Next.js 15**, the default mindset is changing: ✅ Fetch data on the server ✅ Keep sensitive logic off the client ✅ Send less JavaScript to the browser ✅ Improve performance and initial load times That’s a big deal. But let’s be clear: **client-side rendering isn’t dead**. We still need client components for: - interactivity - local state - animations - browser-only APIs - rich UI experiences What’s really happening is this: **We’re getting better boundaries.** Instead of treating the entire app like it needs to run in the browser, we can now choose: - **Server Components** for data-heavy, static, and secure parts - **Client Components** for interactive UX That means better performance *and* cleaner architecture. The real question isn’t **“Is this the end of client-side rendering?”** It’s: **“Why were we rendering so much on the client in the first place?”** Next.js 15 doesn’t kill CSR. It makes it **intentional**. And that’s probably the bigger evolution. #nextjs #react #webdevelopment #javascript #frontend #performance #servercomponents #fullstack #WebDevelopment #TypeScript #Frontend #JavaScript
To view or add a comment, sign in
-
-
𝗧𝗵𝗲 𝗗𝗶𝗳𝗳𝗲𝗿𝗲𝗻𝗰𝗲 𝗕𝗲𝘁𝘄𝗲𝗲𝗻 𝗥𝗲𝗮𝗰𝘁 𝗮𝗻𝗱 𝗡𝗲𝘅𝘁.𝗷𝘀 You use React and Next.js to build projects. What do you learn from this experience? Both are powerful and widely used. They solve different problems in real-world development. React gives you freedom. You build interfaces exactly how you want. Next.js builds on top of React. It adds structure through file-based routing, rendering strategies, API routes, and performance optimizations. Here's how they differ: - React uses Client-Side Rendering (CSR) by default. The browser loads a minimal HTML file. JavaScript is downloaded and executed. React then builds and renders the UI in the browser. - Next.js offers more rendering strategies: • CSR - same behavior as React when needed • SSR - HTML is generated on each request • SSG - pages are pre-built at build time • ISR - static pages that can update in the background • RSC - components rendered on the server without sending unnecessary JavaScript to the client Next.js uses file-based routing. Each file becomes a route automatically. React requires external routing libraries like react-router-dom. Next.js includes many optimizations out of the box, such as automatic code splitting, image optimization, font optimization, and link prefetching. React requires manual performance optimization. Both use the same state tools: • useState • useContext • Redux Toolkit • Zustand • Jotai • Recoil • React Query / SWR Next.js supports React Server Components, which can reduce the need for some client-side state in server-driven parts of an app. In the end, React and Next.js are not competitors. They are different layers of the same ecosystem. React gives you flexibility. Next.js provides structure, performance optimizations, and full-stack capabilities out of the box. Source: https://lnkd.in/gfyfF7BR
To view or add a comment, sign in
-
Stop sending messy, 100-character links to your users. 🛑 I just finished building an Admin Panel that solves the "ugly URL" problem. This tool allows admins to generate clean, SEO-friendly slugs in seconds, keeping the front-end architecture organized and the user experience professional. The Tech Stack: Frontend: React & Tailwind CSS for a sleek, responsive UI. Logic: Dynamic slug generation with real-time availability previews. Security: Integrated Sign-in/Sign-up flow to ensure data integrity. Building this taught me a lot about managing state across authentication states and optimizing the CRUD flow. Check out the walkthrough below! 👇 #WebDevelopment #ReactJS #TailwindCSS #CodingJourney #AdminPanel #FullStack
To view or add a comment, sign in
-
Next.js feels complicated for one reason You’re shipping too much to the browser. That’s it. Next.js is server-first. React is client-first. Mix them wrong → everything breaks (performance, bundle size, clarity). The rule: If it doesn’t need clicks → keep it on the server If it needs interaction → move it to the client And yet most devs do this: - "use client" - "use client" - "use client" Congrats — you just turned Next.js back into React. Real example: Dashboard page: Data, layout, rendering → Server Search, filters, UI state → Client That split alone can cut your JS by a lot. Next.js isn’t complex. You’re just using it like it’s not Next.js. #NextJS #React #WebPerf #Frontend #JavaScript #BuildInPublic
To view or add a comment, sign in
More from this author
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development
Can u explain what is it