Server Components (default) in Next.js

From the Next.js cheat sheet · Server & Client Components · verified Jul 2026

Server Components (default)

typescript
// Server Component (default) - No 'use client'
// app/products/page.tsx

interface Product {
  id: string
  name: string
  price: number
}

// Can be async and fetch data directly
export default async function ProductsPage() {
  // Direct database access or API calls
  const products = await fetch('https://api.example.com/products', {
    cache: 'force-cache' // Cache strategy
  }).then(res => res.json())

  // Can access environment variables directly
  const secretKey = process.env.SECRET_API_KEY

  // Can import server-only modules
  const db = await import('@/lib/db')
  const users = await db.getUsers()

  return (
    <div>
      <h1>Products</h1>
      {products.map((product: Product) => (
        <div key={product.id}>
          <h2>{product.name}</h2>
          <p>${product.price}</p>
        </div>
      ))}
    </div>
  )
}

// Server Component with children
export async function ServerWrapper({ children }: { children: React.ReactNode }) {
  const data = await fetchData()
  
  return (
    <div>
      <h1>{data.title}</h1>
      {children} {/* Can be Client Components */}
    </div>
  )
}
💡 Components are Server Components by default
⚡ Can fetch data directly with async/await
📌 Reduces JavaScript sent to client
🔥 Cannot use browser APIs or event handlers

Continue with Next.js

Save the full cheat sheet or work through every related task.

More Next.js tasks

Back to the full Next.js cheat sheet