> For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt.

# Function: createContext()

> **createContext**\<`T`>(`defaultValue`: `T`): `Context`\<`T`>

Lets you create a [Context](https://react.dev/reference/react/createContext#context-provider) that components can provide or read.

## Type Parameters

| Type Parameter |
| -------------- |
| `T`            |

## Parameters

| Parameter      | Type | Description                                                                                                                                                                                                                           |
| -------------- | ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `defaultValue` | `T`  | The value you want the context to have when there is no matching [Provider](https://react.dev/reference/react/createContext#provider) in the tree above the component reading the context. This is meant as a "last resort" fallback. |

## Returns

`Context`\<`T`>

## See

- [React Docs](https://react.dev/reference/react/createContext#reference)
- [React TypeScript Cheatsheet](https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/context/)

## Example

```tsx
import { createContext } from 'react';

const ThemeContext = createContext('light');
function App() {
  return (
    <ThemeContext value="dark">
      <Toolbar />
    </ThemeContext>
  );
}
```
