arrow_backBACK TO DRILLS
Blue Beltserver-componentsPREMIUM
createContext Requires a 'use client' Directive in Next.js App Router
This provider file has no directive at the top and is imported into app/layout.tsx, a Server Component.
REACT_MODULE // 0x42
// app/providers.tsx
import { createContext, useState } from 'react';
export const ThemeContext = createContext('dark');
export function ThemeProvider({ children }) {
const [theme] = useState('dark');
return (
<ThemeContext.Provider value={theme}>{children}</ThemeContext.Provider>
);
}The build fails with an error about createContext being unavailable. What is the correct fix?