Dark Theme in NextJs 13 – Using React Context in Server Components @hamedbahram
Dark Theme in NextJs 13 – Using React Context in Server Components  @hamedbahram
Uploaded June 2023 | Updated December 2026, 3 hours ago
In this video, we'll look at adding a dark/light theme to NextJs 13 using the `next-themes` package. We'll also learn how to use React context in Server components.

UPDATE: Manually adding the `class` and `style` attributes might not resolve the hydration mismatch problem in some cases. I've updated the source code to use the `suppressHydrationWarning` prop from React instead.

πŸ‘‰πŸΌ The Ultimate NextJs Course
πŸ”— hamedbahram.io/courses/nextjs

πŸ‘‰πŸΌ Source code (Github)
πŸ”— github.com/HamedBahram/next-starter-with-theme

πŸ‘‰πŸΌ next-themes package
πŸ”— npmjs.com/package/next-themes?activeTab=readme


Chapters
0:00 Intro
0:20 Project setup
3:00 Adding next-themes
4:00 Using React context
6:15 Adding a header
8:00 Using Tailwind dark variant
11:00 Adding Theme toggle button
13:20 Adding HeroIcons
14:20 Resolve hydration mismatch
15:30 Resolve extra attribute warning
18:52 Outro
Dark Theme in NextJs 13 – Using React Context in Server ComponentsUsing React Hook Form, Zod Validation and Server Actions in NextJsServerless Postgres ft Mahmoud from NeonAdvanced authentication in NextJs using middleware & server actionsThe new `useTransition` hook with 3 example usecasesUsing NextUI Components & Themes in NextJsUnlocking the Power of AI with Vercel SDK ft Nico AlbaneseBuild an ecommerce site using NextJS and SwellTanStack Start: Server Components Without the Mental GymnasticsLoading Skeleton for Search & Pagination in NextJs 13 Movie AppAnimating Background Gradients using Framer MotionTen UI Libraries, Components, and Tools I Use
Hamed Bahram |

Dark Theme in NextJs 13 – Using React Context in Server Components

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER