DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk6 min

How to Fetch Data in Next.js Server and Client Components

Use Server Components for data fetching by default in the Next.js App Router. Choose Client Components for browser-driven behavior, and configure caching and loading boundaries deliberately.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In the Next.js App Router, fetch data in a Server Component by default: pages and layouts are Server Components unless you mark a module with 'use client'. Fetch in a Client Component when the request depends on browser behavior, user interaction, effects, or client-side state. The right choice affects where credentials and query logic run, how much JavaScript reaches the browser, and how loading and caching work.

Choose the server or client based on what the data needs

Server Components can read from APIs, databases, or an ORM near the data source. Keeping those calls on the server keeps server-only query logic and credentials out of the client bundle, and avoids making the browser perform work that does not require it. They can also stream rendered UI as data becomes available.

As an Amazon Associate I earn from qualifying purchases.

Use a Client Component when fetching is part of a browser interaction—for example, when the user changes a filter and the page updates without a navigation—or when the component needs effects, browser APIs, event handlers, or client state. Mark that module with 'use client'. Its imports and descendants become part of the client module graph, so keep the boundary as narrow as the feature allows.

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

For most pages, a useful division is to load initial data in a Server Component and pass the result to a smaller Client Component for interactive controls. This is a design choice, not a rule that all data must come from one side. See Next.js’s Server and Client Components guide.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Fetch data in a Server Component

Make the component asynchronous, await the request, parse the response, and render the result. Keep the request near the component that needs its data. Identical fetch requests in a React component tree are memoized by default, according to the current Next.js fetching guide.

export default async function Page() {
  const response = await fetch('https://api.example.com/items')

  if (!response.ok) {
    throw new Error('Failed to fetch items')
  }

  const items = await response.json()
  return <ItemList items={items} />
}

The URL here is illustrative; replace it with your endpoint and handle errors according to your application. The response.ok check matters because fetch does not treat every HTTP error status as a rejected promise. The official guide’s basic pattern is to await the request, parse its response, and render the data: Fetching Data in the App Router.

Query a database or ORM on the server

A Server Component can call a database or ORM directly instead of making an HTTP request to your own backend. The database client and query logic stay out of the client bundle. That does not remove the need for access controls: authenticate the request and authorize the user for the specific records returned.

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.
Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
export default async function Page() {
  const items = await db.item.findMany()
  return <ItemList items={items} />
}

Fetch in a Client Component when the browser must manage it

Client-side fetching suits data that changes in response to browser interaction, client state, or an effect. A direct effect-based example looks like this:

'use client'

import { useEffect, useState } from 'react'

export function ItemList() {
  const [items, setItems] = useState([])
  const [error, setError] = useState(null)

  useEffect(() => {
    let active = true

    async function loadItems() {
      try {
        const response = await fetch('/api/items')
        if (!response.ok) throw new Error('Request failed')
        const data = await response.json()
        if (active) setItems(data)
      } catch (err) {
        if (active) setError(err)
      }
    }

    loadItems()
    return () => { active = false }
  }, [])

  if (error) return <p>Could not load items.</p>
  return <ItemListView items={items} />
}

This illustrates the boundary and basic lifecycle; a real component should also define its loading UI and adapt error handling to the application. Do not put secret API credentials in client code: anything sent to the browser is not a server-side secret.

For client-managed requests, the Next.js guide demonstrates SWR and also identifies React Query as a community option. These libraries have their own cache and streaming behavior; that behavior is not the same as Next.js server-side fetch caching. Choose one when its client-side coordination, revalidation, or interaction model fits the feature.

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Stream a promise when server and client work together

A Server Component can start a request without awaiting it, pass the promise to a Client Component, and let that component read it with React’s use API under a Suspense boundary. This lets the surrounding UI render while the data-dependent part waits.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
// Server Component
import { Suspense } from 'react'
import ItemPanel from './item-panel'

export default function Page() {
  const itemsPromise = getItems()

  return (
    <Suspense fallback={<p>Loading items…</p>}>
      <ItemPanel itemsPromise={itemsPromise} />
    </Suspense>
  )
}
// Client Component
'use client'

import { use } from 'react'

export default function ItemPanel({ itemsPromise }) {
  const items = use(itemsPromise)
  return <ItemList items={items} />
}

Follow the current Next.js and React guidance for passing promises across the Server/Client boundary and handling rejection. The relevant pattern is documented in the Next.js fetching guide.

Run independent requests in parallel

If two requests do not depend on one another, start both before awaiting either. This avoids making the second request wait unnecessarily for the first.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
const itemsPromise = getItems()
const categoriesPromise = getCategories()

const [items, categories] = await Promise.all([
  itemsPromise,
  categoriesPromise,
])

Promise.all rejects if any input promise rejects. Use Promise.allSettled instead if the page should collect each request’s success or failure independently. If one request needs a value returned by another, that dependency makes the sequence necessary.

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

Make caching and freshness an explicit choice

Do not assume every Next.js version and configuration uses the same cache defaults. The current App Router fetching guide says fetch requests are not cached by default, while the fetch API reference describes individual cache and revalidation options. The meaning of the default also depends on prerendering and the project’s Cache Components configuration. Check which model your project uses before relying on an assumed lifetime.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Option Effect Use it when
cache: 'no-store' Fetch from the remote source on every request. The response must be obtained from the source for each request.
cache: 'force-cache' Use the Next.js Data Cache, fetching again when there is no fresh match. A cached response is appropriate for the data.
next: { revalidate: false } Do not revalidate by time. The resource should remain cached until another invalidation mechanism applies.
next: { revalidate: 0 } Set the resource’s revalidation interval to zero. Use only with an understanding of the project’s current fetch semantics.
next: { revalidate: seconds } Set a time-based revalidation interval in seconds. Some staleness is acceptable in exchange for reuse.
next: { tags: ['items'] } Associate a tag for later on-demand revalidation. You need to invalidate related cached data by tag.

Do not combine cache: 'no-store' with a numeric next.revalidate; the fetch reference documents those conflicting options as invalid. Its description of auto no cache includes build-time prerendering behavior, so it should not be summarized as “always uncached.” Consult the current Next.js fetch API reference for the exact option semantics.

Next.js documents a previous caching model for projects not using Cache Components and a separate revalidation guide for Cache Components. In the latter, time-based revalidation uses cacheLife; on-demand invalidation can use revalidateTag, updateTag, or revalidatePath. These are configuration-specific approaches, not interchangeable instructions. See Caching without Cache Components and Revalidating.

Show a loading state while data resolves

An uncached or slow server request can delay the part of the route that depends on it. Add a route-segment loading.js or a component-level <Suspense> boundary to provide a fallback while the result resolves. Make the fallback useful for the content it replaces—for example, a table-shaped placeholder rather than a generic blank area.

Place the boundary close to the slow access when necessary. A same-segment loading.js does not necessarily cover runtime or uncached access performed in a layout; placing Suspense near that access or moving the access into the page can make the loading boundary effective. The current fetching guide covers both route loading files and component-level streaming.

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

Keep older cache guidance in its version context

Next.js 15 documentation described fetch responses as not cached by default while route output could still be prerendered and cached. That is historical, version-specific guidance, not a universal rule for current projects. If maintaining a Next.js 15 application, use the matching Next.js 15 fetching guide rather than applying current Cache Components instructions without checking compatibility.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.