Getting Started
  • Introduction
  • Installation
  • About
Core Concepts
  • Routing System
  • Page Functions
  • Data Fetching
  • Server Components
  • Client Components
Features
  • Dynamic & Query Parameters
  • Navigation
  • Styles & CSS
  • Images
  • Favicons
Configuration
  • Environment Variables
  • Import Aliases
  • Ejecting
dinou logodinou
docs
npmGitHub

Client Components

Learn how to properly define Client Components in dinou.

Overview

Client Components in dinou must begin with the "use client"; directive at the top of the file if they are not imported by other client components.

This applies to files like page.tsx, layout.tsx, not_found.tsx, and error.tsx, since they are entry points and not imported by other components directly.

To avoid surprises, it's recommended to include the "use client"; directive in all client components.

Example

// Client Component page
"use client";

import { useState } from "react";

export default function Page() {
  const [count, setCount] = useState(0);

  return (
    <div>
      <h1>Counter Example</h1>
      <p>Current count: {count}</p>
      <button onClick={() => setCount(count + 1)}>Increment</button>
    </div>
  );
}

On This Page

Overview