createContext & useContext in SolidJS

From the SolidJS cheat sheet · Context · verified Jul 2026

createContext & useContext

Create and consume context to share state across deeply nested components.

tsx
// Quick Reference
import { createContext, useContext } from "solid-js";

const ThemeCtx = createContext("light");
// Provider: <ThemeCtx.Provider value="dark">
// Consumer: const theme = useContext(ThemeCtx);
💡 Context values can include signals and setters for reactive shared state
⚡ Create a custom useX hook that throws if context is missing for better DX
📌 Context is great for themes, auth, i18n, and other app-wide state
🟢 Unlike React, context consumers don't re-render — only the signal reads update
contextstate-sharingprovider
Back to the full SolidJS cheat sheet