Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use next/dynamic for components, native import() for libraries triggered by user actions, and next/image for images. Keep dynamic imports explicit and at module scope, add a useful loading state, and use ssr: false only when a Client Component depends on browser-only APIs. Server Components are already code-split, so most manual lazy-loading work targets Client Components and large on-demand libraries.

What lazy loading does in Next.js

Lazy loading defers code or media until it is needed, reducing the JavaScript required to render the initial route. The Next.js documentation describes this as improving initial loading performance by decreasing the amount of JavaScript needed to render a route (official App Router guide, updated February 27, 2026). It is not a guaranteed percentage improvement: the result depends on your bundles, network, device and which code is actually deferred, so measure your own application.

  • Client Components: the main target for component-level lazy loading.
  • Server Components: automatically code split by Next.js; manual dynamic loading is usually unnecessary.
  • Libraries: load expensive packages when a user starts the relevant task.
  • Images: use the optimized next/image component, which defaults to native lazy loading.

Choose the right mechanism

Target Recommended API When it loads SSR considerations
Client component next/dynamic Initial render or conditional render SSR remains on by default
Client component with Suspense React.lazy plus <Suspense> When React renders the lazy component Use a boundary with a fallback
Browser-only component next/dynamic(..., { ssr: false }) Client side only Only valid from a Client Component
Large library Native import() On an event such as typing or clicking Run in client code when browser APIs are involved
Image next/image Near viewport by default Use eager selectively above the fold

Lazy-load a component with next/dynamic

In a Client Component, import dynamic and declare the dynamic component at module scope:

'use client'

import dynamic from 'next/dynamic'

const Chart = dynamic(() => import('../components/Chart'), {
  loading: () => <p>Loading chart…</p>,
})

export default function Dashboard() {
  return (
    <main>
      <h1>Dashboard</h1>
      <Chart />
    </main>
  )
}

The import must be inside the dynamic() call, use an explicit path, and remain at module scope. The Pages Router documentation explains that this lets Next.js match the import to a webpack bundle and preload it before rendering. Do not use a template string or variable path such as import(path); Next.js cannot reliably map that to a specific module.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Defer a component until it is needed

Conditional rendering prevents the chunk from being requested until the feature is opened:

'use client'

import { useState } from 'react'
import dynamic from 'next/dynamic'

const Modal = dynamic(() => import('../components/Modal'))

export default function Settings() {
  const [showModal, setShowModal] = useState(false)

  return (
    <>
      <button onClick={() => setShowModal(true)}>Open settings</button>
      {showModal ? <Modal onClose={() => setShowModal(false)} /> : null}
    </>
  )
}

This pattern is useful for dialogs, charts, editors and other code that most visitors never use. Keep the trigger usable while the chunk downloads and provide a fallback when the wait is visible.

Use React.lazy and Suspense

React.lazy is the other supported component mechanism. Wrap the lazy component in a Suspense boundary:

'use client'

import { lazy, Suspense } from 'react'

const Chart = lazy(() => import('../components/Chart'))

export default function Dashboard() {
  return (
    <Suspense fallback={<p>Loading chart…</p>}>
      <Chart />
    </Suspense>
  )
}

Choose next/dynamic when you want Next.js-specific options such as ssr: false or a component-level loading function. Choose React.lazy when you already organize loading around React Suspense boundaries. In either case, test the fallback, error behavior and layout shift.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Disable server rendering for browser-only components

Some components read window, document, WebGL or another browser-only API during render. Disable SSR for that component from a Client Component:

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
'use client'

import dynamic from 'next/dynamic'

const Map = dynamic(() => import('../components/Map'), {
  ssr: false,
})

export default function LocationPage() {
  return <Map />
}

ssr: false prevents the component from rendering on the server, avoiding reference errors and hydration mismatches. It is not supported in a Server Component; put the dynamic declaration in a file beginning with 'use client'. Prefer fixing a component that can render safely on the server when possible, because disabling SSR removes its server-rendered HTML and can delay visible content.

Load an external library after user input

For a large package used only in an interaction, use native import() inside the event handler. The official guide demonstrates this with Fuse.js:

'use client'

import { useState } from 'react'

export default function Search({ items }) {
  const [results, setResults] = useState(items)

  const onSearch = async (value) => {
    if (!value) {
      setResults(items)
      return
    }

    const Fuse = (await import('fuse.js')).default
    const fuse = new Fuse(items, { keys: ['title'] })
    setResults(fuse.search(value).map(({ item }) => item))
  }

  return (
    <>
      <input onChange={(event) => onSearch(event.target.value)} />
      <ul>{results.map((item) => <li key={item.id}>{item.title}</li>)}</ul>
    </>
  )
}

Debounce high-frequency events such as typing, cache the imported module or initialized object when appropriate, and handle a user navigating away while the import is pending. Dynamic import is not a substitute for removing an unnecessary dependency; inspect the production bundle to confirm the package moved out of the initial chunk.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Route-level loading states

For the App Router, add app/segment/loading.tsx beside the route that needs an instant fallback:

export default function Loading() {
  return <p>Loading dashboard…</p>
}

Next.js can stream this fallback immediately and automatically swap in the completed route. See the loading.js file-convention reference. Use route loading files for navigation and Suspense or next/dynamic fallbacks for parts of an already-rendered page.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Lazy-load images with next/image

The Image API sets loading="lazy" by default, so images near (rather than at) the viewport are fetched as the browser needs them:

import Image from 'next/image'

export default function ArticleHero() {
  return (
    <Image
      src="/hero.jpg"
      alt="A laptop displaying a Next.js dashboard"
      width={1200}
      height={800}
      loading="eager"
    />
  )
}

The explicit attribute above documents the intent; omitting it keeps the same default. For an above-the-fold image that determines the first view, use loading="eager" (or the current preload option documented by your Next.js version) selectively. Do not mark every image eager: that defeats deferred loading and consumes bandwidth early. Native lazy loading may fall back to eager behavior in browsers older than Safari 15.4, according to the Image API reference.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Image details that still matter

  • Provide accurate width and height, or a supported fill layout, to reserve space and reduce layout shift.
  • Keep meaningful alt text; decorative images should use an empty alt value.
  • Configure remote image hosts in next.config.js before using external URLs.
  • Use responsive sizes and appropriately compressed source files; lazy loading cannot fix oversized images that are eventually downloaded.

Implementation checklist

  1. Identify code that is not needed for the first view: charts, editors, maps, dialogs and rarely used widgets.
  2. Keep Server Components on the server where possible; add a Client boundary only for interactive code.
  3. Declare explicit dynamic imports at module scope.
  4. Choose an initial-render import, conditional render, or event-triggered native import based on when the feature is needed.
  5. Add a stable loading UI that reserves space and communicates progress.
  6. Use ssr: false only for genuine browser-only components.
  7. Use next/image defaults for below-the-fold media and eager loading only for critical above-the-fold images.
  8. Build for production and compare initial JavaScript, requests, Largest Contentful Paint, interaction readiness and layout shift before and after.

Common failures and fixes

“window is not defined”

Cause: browser code executes during server rendering. Fix: move the component behind a Client Component boundary and use dynamic(() => import('./Component'), { ssr: false }), or move the browser call into an effect that runs after mount.

The dynamic chunk appears in the initial bundle

Cause: the module is also imported statically elsewhere, or the feature renders immediately and is therefore requested immediately. Fix: remove duplicate static imports and render the dynamic component only when needed. Verify with a production bundle analyzer.

“Invalid dynamic suspense” or an SSR option error

Cause: ssr: false was used from a Server Component, or Suspense configuration conflicts with the framework version. Fix: put the declaration in a Client Component and follow the version-matched Next.js API reference.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Loading UI causes a jump

Cause: the fallback has a different size from the final component. Fix: reserve the chart, image or panel dimensions in the fallback and use skeleton content with the same geometry.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Images still load immediately

Cause: the image is above the viewport, the browser does not support native lazy loading, or eager was set. Fix: inspect the rendered attributes and network waterfall, and test on the browsers you support; Safari versions older than 15.4 can fall back to eager loading.

Search feels slow on the first keystroke

Cause: the library download and initialization occur during the interaction. Fix: debounce input, show a pending state, preload on focus when appropriate, or keep a small frequently used library in the initial bundle.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, reliability and cost notes

Lazy loading trades initial cost for later cost. A deferred chunk still takes network time, parse time and memory when requested, and a slow connection can make an interaction feel worse than a slightly larger initial bundle. Keep critical content server-rendered, prefetch only predictable next actions, and avoid dozens of tiny chunks that create request overhead. Measure with production builds on representative devices and networks; no authoritative universal percentage improvement is established for this implementation.

For reliability, make fallbacks accessible, handle import failures with an error boundary, and ensure the page remains useful if JavaScript is delayed. Test direct navigation, client navigation, hard refreshes, offline or flaky-network behavior, and the browser matrix your application supports.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Or skip the browser setup

If your goal is a clean screenshot of the page after lazy-loaded content settles, ScreenshotNeo provides a single website screenshot API call instead of maintaining Playwright or browser infrastructure. It can wait for a selector, a delay or network idle; load lazy images; execute custom JavaScript; choose a viewport or device preset; capture an element; and return PNG, JPEG, WebP or PDF.

Use this cURL request (see the ScreenshotNeo documentation):

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Cookie and consent banners, newsletter popups and chat widgets are removed before the shot. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing status. ScreenshotNeo also offers an MCP server with take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots, and every feature is available on every plan. Create a free ScreenshotNeo account.

FAQ

Should I use next/dynamic or React.lazy?

Use next/dynamic for Next.js options and straightforward framework integration; use React.lazy when your component tree already uses Suspense boundaries. Both defer a component chunk.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can I lazy-load a Server Component?

Server Components are already code split by Next.js. Apply manual lazy loading mainly to Client Components, browser-only code and on-demand libraries.

Does lazy loading guarantee better Core Web Vitals?

No. It can reduce initial JavaScript, but a delayed critical component can hurt visual completion or interaction latency. Measure the production route and choose what to defer.

When should an image be eager?

Only when it is genuinely critical to the first viewport, such as a primary hero image. Keep ordinary below-the-fold images on the default lazy behavior.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.