# createContext

```ts
function createContext<T>(name: string, defaultValue?: T): Context<T>
```

Create a new [Context](https://frontside.com/effection/api/v4/Context.md)

### Examples
#### Example 1
```ts
import { createContext, main } from "effection";

const YourContext = createContext<string>("context-id");

await main(function* () {
  yield* YourContext.with("abc-123", function* () {
    console.log(yield* YourContext.expect()); // "abc-123"
  });
});
```

---
### Type Parameters
T


### Parameters


**name**: string


the unique name to give this context.


**defaultValue**<span class="inline-block bg-sky-100 rounded px-2 text-sm text-sky-900 mx-1">optional</span>: T
### Return Type


[Context](https://frontside.com/effection/api/v4/Context.md)&lt;T&gt;


the new context

[View code](https://github.com/thefrontside/effection/tree/effection-v4.2.0/lib/context.ts#L25)
