AEAl-Andalus⺢Experience
Sign in · Join
AEAl-Andalus⺢Experience
ProjectsGalleryAboutArticlesDashboardAPI
© 2026 — Modular content systems☕buy me a coffee
Framework Study Guide
ChaptersCardsLegendRoadmapRoute Map
Chapters
00 · Root Layout01 · Server Page (page.tsx)01a · Special Files (not-found, error, loading)02 · Client Component (UI & Interaction)02a · Client Boundaries & Islands03 · Entity Actions (actions/*.ts)04 · Server Actions ("use server")05 · Context Provider (context/*.tsx)06 · API Route (app/(api)/<entity>/route.ts)07 · TypeScript + Prisma08 · Entity-First Feature Design09 · Deployment, Docker & Cloud10 · Next 16 + Prisma 7 Upgrade11 · Prisma 7 (SQLite-first, App Router)12 · TypeORM (Entities + Migrations)13 · Drizzle ORM (SQL-first)11 · CSS, Mobile-First Flex, Tailwind12 · Libraries, Accelerators & Production Shortcuts14 · Next.js 16: cache, PPR, proxy, AI
→ cards/05-context-provider

Chapter

05 · Context Provider (context/*.tsx)

UI state sharing only: convenience, not authority; never fetch or mutate data.

Mental Model

  • Context remembers UI state (layout, edit mode), not entity truth.
  • If removing context breaks correctness, context was misused.

File Classification

Layer: UI ergonomics
Directive: "use client"
Runtime: Browser
Prisma: ❌ Never
Server Actions: ❌ Never
Data authority: ❌ Never

Canonical Example

"use client";
import { createContext, useContext, useState } from "react";

type UIState = { isGrid: boolean; toggle: () => void; };
const UIContext = createContext<UIState | null>(null);

export function UIProvider({ children }: { children: React.ReactNode; }) {
const [isGrid, setIsGrid] = useState(false);
return (
<UIContext.Provider value={{ isGrid, toggle: () => setIsGrid((v) => !v) }}>
{children}
</UIContext.Provider>
);
}

export function useUI() {
const ctx = useContext(UIContext);
if (!ctx) throw new Error("useUI must be inside UIProvider");
return ctx;
}

Never Do (and where it belongs)

  • Prisma or fetch → keep in entity/server actions.
  • Permissions/auth → server pages + entity actions.
  • Entity truth/state → server; context is UI-only.