Skip to content

🎯 Learn modern React patterns with Next.js - Server Components, streaming SSR, use hook, and accessibility best practices. Interactive demos with TypeScript & Tailwind CSS.

Notifications You must be signed in to change notification settings

anton-karlovskiy/react-minimal-concepts-with-next

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

React Minimal Concepts with Next.js

A comprehensive collection of React demos showcasing modern patterns, Server Components, streaming SSR, and accessibility best practices.

Next.js React TypeScript Tailwind CSS

πŸš€ Features

React Demos

  • Server Components with Streaming SSR - Learn how to build async Server Components with progressive content loading
  • Server-Client Promise Streaming - Master the use hook for seamless server-client data streaming
  • useId Hook for Accessibility - Implement proper ARIA relationships and unique ID generation

Modern Development Stack

  • ⚑ Next.js with Turbopack for lightning-fast development
  • βš›οΈ React with latest features and Server Components
  • 🎨 Tailwind CSS for modern, responsive styling
  • πŸ“˜ TypeScript for type-safe development
  • πŸ”§ ESLint for code quality and consistency

🎯 What You'll Learn

Server Components & Streaming SSR

  • How to build async Server Components that run on the server
  • Implementing progressive content loading with Suspense boundaries
  • Reducing client bundle size with server-side rendering
  • Accessing server-side data sources directly in components

React use Hook

  • Streaming data from server to client without blocking
  • Handling promises in Client Components with the use hook
  • Building responsive UIs with progressive enhancement
  • Optimizing perceived performance with streaming

Accessibility with useId

  • Generating unique IDs for ARIA relationships
  • Preventing ID conflicts in multiple component instances
  • Server-side rendering compatibility for accessibility
  • Building accessible forms and interactive components

πŸ› οΈ Quick Start

Prerequisites

  • Node.js 18+
  • npm, yarn, pnpm, or bun

Installation

# Clone the repository
git clone https://github.com/your-username/react-minimal-concepts-with-next.git
cd react-minimal-concepts-with-next

# Install dependencies
npm install
# or
yarn install
# or
pnpm install
# or
bun install

Development

# Start development server with Turbopack
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev

Open http://localhost:3000 to see the demos in action.

Build for Production

# Build the application
npm run build
# or
yarn build
# or
pnpm build
# or
bun build

# Start production server
npm start
# or
yarn start
# or
pnpm start
# or
bun start

πŸ“š Demo Components

1. Server Components + Streaming SSR

File: app/components/StreamingSSRDemo.tsx

Demonstrates React 19 Server Components with streaming SSR:

  • Async Server Components with direct database/API access
  • Progressive content loading with Suspense boundaries
  • Reduced client bundle size through server-side rendering
  • Real-world data fetching patterns

2. Server-Client Promise Streaming

File: app/components/PostWithCommentsDemo.tsx

Shows the use hook for seamless server-client streaming:

  • Critical content (post) rendered immediately on server
  • Lower-priority content (comments) streamed to client
  • Promise-based data flow between server and client
  • Enhanced user experience with progressive loading

3. useId Hook for Accessibility

File: app/components/UseIdDemo.tsx

Comprehensive accessibility patterns with useId:

  • Unique ID generation for ARIA relationships
  • Multiple related elements with shared ID prefixes
  • Server-side rendering compatibility
  • Form accessibility best practices

πŸ—οΈ Project Structure

react-minimal-concepts-with-next/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ StreamingSSRDemo.tsx      # Server Components demo
β”‚   β”‚   β”œβ”€β”€ PostWithCommentsDemo.tsx # use Hook demo
β”‚   β”‚   β”œβ”€β”€ UseIdDemo.tsx            # useId accessibility demo
β”‚   β”‚   └── UI/                      # Reusable UI components
β”‚   β”œβ”€β”€ globals.css                  # Global styles
β”‚   β”œβ”€β”€ layout.tsx                   # Root layout
β”‚   └── page.tsx                     # Home page
β”œβ”€β”€ public/                          # Static assets
β”œβ”€β”€ package.json                     # Dependencies and scripts
β”œβ”€β”€ tailwind.config.js              # Tailwind configuration
β”œβ”€β”€ tsconfig.json                   # TypeScript configuration
└── next.config.ts                  # Next.js configuration

🎨 UI Components

The project includes a set of reusable UI components:

  • Card - Container component with consistent styling
  • DemoTitle - Standardized demo section headers
  • Code - Syntax-highlighted code blocks
  • Button, Input, Textarea - Form components
  • FallbackLoading - Loading states for Suspense

πŸ”§ Technologies Used

πŸ“– Key Concepts Explained

Server Components

Server Components run on the server and can access databases, file systems, and other server-side resources directly. They're not sent to the client, reducing bundle size.

Streaming SSR

Progressive content loading where the page shell renders immediately, and content streams in as it becomes available, improving perceived performance.

use Hook

React's use hook allows Client Components to consume promises passed from Server Components, enabling seamless server-client data streaming.

useId Hook

Generates unique, stable IDs for accessibility attributes, ensuring proper ARIA relationships and server-side rendering compatibility.

πŸš€ Deployment

Vercel (Recommended)

The easiest way to deploy is using Vercel:

Deploy with Vercel

Other Platforms

This Next.js application can be deployed to any platform that supports Node.js:

  • Netlify
  • AWS Amplify
  • Railway
  • Render
  • DigitalOcean App Platform

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is open source and available under the MIT License.

πŸ™ Acknowledgments

πŸ“ž Support

If you have any questions or need help with the demos, please:


Built with ❀️ using React, Next.js, and modern web technologies